Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez committed May 21, 2024
1 parent 078da56 commit 78cfb07
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 170 deletions.
35 changes: 4 additions & 31 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# Developer note: near.gitignore will be renamed to .gitignore upon project creation
# dependencies
node_modules
/.pnp
.pnp.js

# build
/out
/dist

# keys
/templates/react/neardev

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
/.cache

npm-debug.log*
yarn-debug.log*
yarn-error.log*
**/node_modules
**/dist
**/.parcel-cache
yarn.lock
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Interact With Multiple Contracts
[![](https://img.shields.io/badge/⋈%20Examples-Intermediate-orange)](https://docs.near.org/tutorials/welcome)
[![](https://img.shields.io/badge/Contract-none-gray)](https://docs.near.org/develop/contracts/anatomy)
[![](https://img.shields.io/badge/Contract-NONE-gray)](https://docs.near.org/develop/contracts/anatomy)
[![](https://img.shields.io/badge/Frontend-JS-yellow)](https://docs.near.org/develop/integrate/frontend)

A frontend-only example showing how to interact with multiple contracts simultaneously.

![](frontend/assets/img-for-github.png)
![](src/assets/img-for-github.png)


# What This Example Shows

1. How to view methods in multiple contracts.
2. How to call methods in multiple contracts simultaneously.
1. How to view methods in multiple contracts
2. How to call methods in multiple contracts simultaneously

<br />

Expand Down
115 changes: 0 additions & 115 deletions frontend/near-wallet.js

This file was deleted.

28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@
},
"devDependencies": {
"buffer": "^5.7.1",
"crypto-browserify": "^3.12.0",
"env-cmd": "^10.1.0",
"events": "^3.3.0",
"https-browserify": "^1.0.0",
"nodemon": "^2.0.16",
"parcel": "^2.7.0",
"process": "^0.11.10"
"process": "^0.11.10",
"stream-browserify": "^3.0.0",
"stream-http": "^3.1.0",
"url": "^0.11.0",
"vm-browserify": "^1.1.2"
},
"dependencies": {
"@near-wallet-selector/core": "^7.0.0",
"@near-wallet-selector/ledger": "^7.0.0",
"@near-wallet-selector/math-wallet": "^7.0.0",
"@near-wallet-selector/meteor-wallet": "^7.0.0",
"@near-wallet-selector/modal-ui": "^7.0.0",
"@near-wallet-selector/my-near-wallet": "^7.0.0",
"@near-wallet-selector/near-wallet": "^7.0.0",
"@near-wallet-selector/nightly": "^7.0.0",
"@near-wallet-selector/nightly-connect": "^7.0.0",
"@near-wallet-selector/sender": "^7.0.0",
"@near-wallet-selector/wallet-connect": "^7.0.0",
"near-api-js": "^0.44.2"
"@near-wallet-selector/core": "^8.9.7",
"@near-wallet-selector/here-wallet": "^8.9.7",
"@near-wallet-selector/modal-ui": "^8.9.7",
"@near-wallet-selector/my-near-wallet": "^8.9.7",
"near-api-js": "^3.0.4"
},
"overrides": {
"near-api-js": "^3.0.4"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
14 changes: 7 additions & 7 deletions frontend/index.js → src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const NO_DEPOSIT = '0';

// Setup on page load
window.onload = async () => {
let isSignedIn = await wallet.startUp();
let signedAccountId = await wallet.startUp(()=>{});

if (isSignedIn) {
signedInFlow();
if (signedAccountId) {
signedInFlow(signedAccountId);
} else {
signedOutFlow();
}
Expand Down Expand Up @@ -62,7 +62,7 @@ async function sendGreeting(event) {
]
}

// Sign **independent** transactions: If one fails, the rest **DO NOT** reverted
// Sign **independent** transactions: If one fails, the other **DOES NOT** revert
await wallet.signAndSendTransactions({ transactions: [ helloTx, guestTx ] })
}

Expand All @@ -73,7 +73,7 @@ async function getGreetingAndMessages() {
// query the last 4 messages in the Guest Book
const totalMessages = await wallet.viewMethod({method: 'total_messages', contractId: GUEST_ADDRESS })
const from_index = (totalMessages > 4? totalMessages - 4: 0).toString();
const latestMessages = await wallet.viewMethod({ method: 'get_messages', contractId: GUEST_ADDRESS, args: {from_index, limit: 4} });
const latestMessages = await wallet.viewMethod({ method: 'get_messages', contractId: GUEST_ADDRESS, args: {from_index, limit: "4"} });

// handle UI stuff
update_UI(currentGreeting, from_index, latestMessages);
Expand All @@ -86,11 +86,11 @@ function signedOutFlow() {
}

// UI: Displaying the signed in flow container and fill in account-specific data
function signedInFlow() {
function signedInFlow(accountId) {
document.querySelector('#signed-out-flow').style.display = 'none';
document.querySelector('#signed-in-flow').style.display = 'block';
document.querySelectorAll('[data-behavior=account-id]').forEach(el => {
el.innerText = wallet.accountId;
el.innerText = accountId;
});
}

Expand Down
Loading

0 comments on commit 78cfb07

Please sign in to comment.