diff --git a/javascript/examples/account-details.js b/javascript/examples/account-details.js index 1448d94..81af1a7 100644 --- a/javascript/examples/account-details.js +++ b/javascript/examples/account-details.js @@ -1,21 +1,17 @@ -import { connect } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; -const connection = await connect({ - networkId: "testnet", - nodeUrl: "https://test.rpc.fastnear.com", +// Gather details through the RPC Provider +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", }); -// Create an account object -const account = await connection.account("example-account.testnet"); +const rpcState = await provider.viewAccount("example-account.testnet"); +console.log({ rpcState }); -// Gets the total, staked and available balance in yoctoNEAR -const accountBalance = await account.getAccountBalance(); -console.log(accountBalance); +// Option 2: Use an Account object +const account = new Account("example-account.testnet", provider); +const accountBalance = await account.getBalance(); +const accountState = await account.getState(); -// Account's state, including its code hash and storage usage -const accountState = await account.state(); -console.log(accountState); - -// Gets a list of authorized apps for an account -const accountDetails = await account.getAccountDetails(); -console.log(accountDetails); +console.log({ accountState, accountBalance }); \ No newline at end of file diff --git a/javascript/examples/batch-actions.js b/javascript/examples/batch-actions.js index e4e735d..5d28809 100644 --- a/javascript/examples/batch-actions.js +++ b/javascript/examples/batch-actions.js @@ -1,36 +1,32 @@ -import { connect, keyStores, KeyPair, transactions, utils } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { actionCreators } from "@near-js/transactions"; +import { NEAR } from "@near-js/tokens"; import dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -const privateKey = process.env.PRIVATE_KEY; -const accountId = process.env.ACCOUNT_ID; -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(privateKey); -await myKeyStore.setKey("testnet", accountId, keyPair); - -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); +// Create a signer from a private key string +const privateKey = process.env.PRIVATE_KEY; +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... -const account = await nearConnection.account(accountId); +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); -// Send a batch of actions to a single receiver -// Prepare the actions -const callAction = transactions.functionCall( - "increment", // Method name - [], // Arguments - "30000000000000", // Gas - 0, // Deposit -); -const transferAction = transactions.transfer(utils.format.parseNearAmount("1")); +// Create an account object +const accountId = process.env.ACCOUNT_ID; +const account = new Account(accountId, provider, signer); // example-account.testnet // Send the batch of actions const batchActionsResult = await account.signAndSendTransaction({ receiverId: "counter.near-examples.testnet", - actions: [callAction, transferAction], + actions: [ + actionCreators.functionCall("increment", {}, "30000000000000", 0), + actionCreators.transfer(NEAR.toUnits("0.1")) + ], }); + console.log(batchActionsResult); diff --git a/javascript/examples/contract-interaction.js b/javascript/examples/contract-interaction.js index e3db355..dc52284 100644 --- a/javascript/examples/contract-interaction.js +++ b/javascript/examples/contract-interaction.js @@ -1,80 +1,40 @@ -import { connect, keyStores, KeyPair, providers } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; + import dotenv from "dotenv"; -import fs from "fs"; dotenv.config({ path: "../.env" }); -const privateKey = process.env.PRIVATE_KEY; -const accountId = process.env.ACCOUNT_ID; -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(privateKey); -await myKeyStore.setKey("testnet", accountId, keyPair); - -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); -const account = await nearConnection.account(accountId); +const contractId = "guestbook.near-examples.testnet"; -// Make a view call to a contract -async function viewContract({ +// Make a read-only function call +const totalMessages = await provider.callFunction( contractId, - methodName, - args = {}, - finality = "optimistic", -}) { - // Set up a new provider - const url = `https://test.rpc.fastnear.com`; - const provider = new providers.JsonRpcProvider({ url }); - - // Convert the arguments to base64 - const argsBase64 = args - ? Buffer.from(JSON.stringify(args)).toString("base64") - : ""; - - // Make the view call - const viewCallResult = await provider.query({ - request_type: "call_function", - account_id: contractId, - method_name: methodName, - args_base64: argsBase64, - finality: finality, - }); + "total_messages", + {} +); - // Parse the result - return JSON.parse(Buffer.from(viewCallResult.result).toString()); -} +console.log({ totalMessages }); -// Use the view call function -const viewCallData = await viewContract({ - contractId: "guestbook.near-examples.testnet", - methodName: "total_messages", -}); -console.log(viewCallData); +// Create a signer from a private key string +const privateKey = process.env.PRIVATE_KEY; +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... -// If args are required, they can be passed in like this: -// args: { -// from_index: "0", -// limit: "10" -// } +// Create an account object +const accountId = process.env.ACCOUNT_ID; +const account = new Account(accountId, provider, signer); // example-account.testnet -// Make a function call to a contract -const contractCallResult = await account.functionCall({ - contractId: "guestbook.near-examples.testnet", // Contract account ID - methodName: "add_message", // Method to call - args: { - text: "Hello, world!", - }, // Arguments for the method - gas: 100000000000000, // Optional: gas limit - attachedDeposit: 0, // Optional: deposit in yoctoNEAR +// Make a function call that modifies state +const result = await account.callFunction({ + contractId: contractId, + methodName: "add_message", + args: { text: "Hello, world!" }, }); -console.log(contractCallResult); -// Deploy a contract to the account -const deployResult = await account.deployContract( - fs.readFileSync("../contracts/contract.wasm"), // Path of contract WASM relative to the working directory -); -console.log(deployResult); +console.log({ result }); \ No newline at end of file diff --git a/javascript/examples/create-account-from-seed.js b/javascript/examples/create-account-from-seed.js index a2d2f0d..2ed1215 100644 --- a/javascript/examples/create-account-from-seed.js +++ b/javascript/examples/create-account-from-seed.js @@ -1,40 +1,27 @@ -import { connect, keyStores, KeyPair, utils } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { NEAR } from "@near-js/tokens"; import { generateSeedPhrase } from "near-seed-phrase"; import dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -const privateKey = process.env.PRIVATE_KEY; -const accountId = process.env.ACCOUNT_ID; -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(privateKey); -await myKeyStore.setKey("testnet", accountId, keyPair); - -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); -const account = await nearConnection.account(accountId); +// Instantiate the account that will create the new account +const signer = KeyPairSigner.fromSecretKey(process.env.PRIVATE_KEY); +const account = new Account(process.env.ACCOUNT_ID, provider, signer); -// Create a .testnet account -// Generate a new account ID based on the current timestamp -const newAccountId = Date.now() + ".testnet"; -// Generate a new seed phrase +// Generate a new key const { seedPhrase, publicKey, secretKey } = generateSeedPhrase(); -console.log("Seed phrase", seedPhrase); -console.log("Private key", secretKey); -console.log("Public key", publicKey); +console.log(`Created key ${secretKey} with seed phrase ${seedPhrase}`); -const createAccountResult = await account.functionCall({ - contractId: "testnet", - methodName: "create_account", - args: { - new_account_id: newAccountId, // example-account.testnet - new_public_key: publicKey, // ed25519:2ASWc... - }, - attachedDeposit: utils.format.parseNearAmount("0.1"), // Initial balance for new account in yoctoNEAR -}); -console.log(createAccountResult); +await account.createTopLevelAccount( + `acc-${Date.now()}.testnet`, + publicKey, + NEAR.toUnits("0.1") +); diff --git a/javascript/examples/create-account.js b/javascript/examples/create-account.js deleted file mode 100644 index c24b4fb..0000000 --- a/javascript/examples/create-account.js +++ /dev/null @@ -1,57 +0,0 @@ -import { connect, keyStores, KeyPair, utils } from "near-api-js"; -import dotenv from "dotenv"; - -dotenv.config({ path: "../.env" }); -const privateKey = process.env.PRIVATE_KEY; -const accountId = process.env.ACCOUNT_ID; - -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(privateKey); -await myKeyStore.setKey("testnet", accountId, keyPair); - -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); - -const account = await nearConnection.account(accountId); - -// Create a .testnet account -// Generate a new account ID based on the current timestamp -const newAccountId = Date.now() + ".testnet"; -// Generate a new key pair -const newKeyPair = KeyPair.fromRandom("ed25519"); -const newPublicKey = newKeyPair.getPublicKey().toString(); -const newPrivateKey = newKeyPair.toString(); -console.log("Private key", newPrivateKey); -console.log("Public key", newPublicKey); - -const createAccountResult = await account.functionCall({ - contractId: "testnet", - methodName: "create_account", - args: { - new_account_id: newAccountId, // example-account.testnet - new_public_key: newPublicKey, // ed25519:2ASWc... - }, - attachedDeposit: utils.format.parseNearAmount("0.1"), // Initial balance for new account in yoctoNEAR -}); -console.log(createAccountResult); - -// Create a sub account -// Generate a new sub account ID based on the current timestamp -const newSubAccountId = Date.now() + "." + accountId; -// Generate a new key pair -const newSubKeyPair = KeyPair.fromRandom("ed25519"); -const newSubPublicKey = newSubKeyPair.getPublicKey().toString(); -const newSubPrivateKey = newSubKeyPair.toString(); -console.log("Private key", newSubPrivateKey); -console.log("Public key", newSubPublicKey); - -const createSubAccountResult = await account.createAccount( - newSubAccountId, // sub.example-account.testnet - newSubPublicKey, // ed25519:2ASWc... - utils.format.parseNearAmount("0.1"), // Initial balance for new account in yoctoNEAR -); -console.log(createSubAccountResult); diff --git a/javascript/examples/create-subaccount.js b/javascript/examples/create-subaccount.js new file mode 100644 index 0000000..db82598 --- /dev/null +++ b/javascript/examples/create-subaccount.js @@ -0,0 +1,36 @@ +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { KeyPair } from "@near-js/crypto"; +import { NEAR } from "@near-js/tokens"; + +import dotenv from "dotenv"; + +dotenv.config({ path: "../.env" }); + +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); + +// Create a signer from a private key string +const privateKey = process.env.PRIVATE_KEY; +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... + +// Create an account object +const accountId = process.env.ACCOUNT_ID; +const account = new Account(accountId, provider, signer); // example-account.testnet + +// Generate a new key pair +const keyPair = KeyPair.fromRandom("ed25519"); +const publicKey = keyPair.getPublicKey().toString(); + +const prefix = Date.now().toString(); + +await account.createSubAccount( + prefix, // prefix for the sub account (e.g. sub.near.testnet) + publicKey, // ed25519:2ASWc... + NEAR.toUnits("0.1") // Initial balance for new account in yoctoNEAR +); + +console.log(`Created ${prefix}.${accountId} with private key ${keyPair.toString()}`) diff --git a/javascript/examples/create-tla.js b/javascript/examples/create-tla.js new file mode 100644 index 0000000..90e8824 --- /dev/null +++ b/javascript/examples/create-tla.js @@ -0,0 +1,51 @@ +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPair } from "@near-js/crypto"; +import { KeyPairSigner } from "@near-js/signers"; +import { NEAR } from "@near-js/tokens"; + +import dotenv from "dotenv"; + +dotenv.config({ path: "../.env" }); + +// Create a signer from a private key string +const privateKey = process.env.PRIVATE_KEY; +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... + +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); + +// Create an account object +const accountId = process.env.ACCOUNT_ID; +const account = new Account(accountId, provider, signer); // example-account.testnet + +// New .testnet account +const newAccountId = Date.now() + ".testnet"; + +// Generate a new key +const keyPair = KeyPair.fromRandom("ed25519"); +const publicKey = keyPair.getPublicKey().toString(); + +await account.createTopLevelAccount( + newAccountId, + publicKey, + NEAR.toUnits("0.1") +); + +console.log(`Created ${newAccountId} with private key ${keyPair.toString()}`) + +// Option 2: Call `testnet` directly +const newAccountId2 = Date.now() + ".testnet"; + +await account.callFunction({ + contractId: "testnet", + methodName: "create_account", + args: { + "new_account_id": newAccountId2, + "new_public_key": publicKey + } +}) + +console.log(`Created account ${newAccountId2} with privateKey: ${keyPair.toString()}`) diff --git a/javascript/examples/delete-account.js b/javascript/examples/delete-account.js index 6d35437..88dbca8 100644 --- a/javascript/examples/delete-account.js +++ b/javascript/examples/delete-account.js @@ -1,47 +1,38 @@ -import { connect, keyStores, KeyPair, utils } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { KeyPair } from "@near-js/crypto"; +import { NEAR } from "@near-js/tokens"; + import dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -const privateKey = process.env.PRIVATE_KEY; -const beneficiaryAccountId = process.env.ACCOUNT_ID; -const myKeyStore = new keyStores.InMemoryKeyStore(); +// Create a signer from a private key string +const privateKey = process.env.PRIVATE_KEY; const keyPair = KeyPair.fromString(privateKey); -await myKeyStore.setKey("testnet", beneficiaryAccountId, keyPair); - -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); - -const accountCreator = await nearConnection.account(beneficiaryAccountId); - -// First create a new account to be deleted -// Generate a new account ID based on the current timestamp -const accountToDeleteId = Date.now() + ".testnet"; -const newKeyPair = KeyPair.fromRandom("ed25519"); -const newPublicKey = newKeyPair.getPublicKey().toString(); - -await accountCreator.functionCall({ - contractId: "testnet", - methodName: "create_account", - args: { - new_account_id: accountToDeleteId, - new_public_key: newPublicKey, - }, - gas: "300000000000000", - attachedDeposit: utils.format.parseNearAmount("0.1"), +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... + +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", }); -// Create an account object for the new account -// and add the new key pair to the keystore -const accountToDelete = await nearConnection.account(accountToDeleteId); -await myKeyStore.setKey("testnet", accountToDeleteId, newKeyPair); +// Create a new account to be deleted +const accountId = process.env.ACCOUNT_ID; +const master = new Account(accountId, provider, signer) + +const deleteMe = `${Date.now()}.testnet`; + +await master.createTopLevelAccount( + deleteMe, + keyPair.getPublicKey().toString(), + NEAR.toUnits("0.1") +); + +// Create an account object for the new account with corresponding signer +const accountToDelete = new Account(deleteMe, provider, signer); -// Delete the account with account ID of the account object -// specifying the beneficiary account ID -const deleteAccountResult = - await accountToDelete.deleteAccount(beneficiaryAccountId); // example-beneficiary.testnet -console.log(deleteAccountResult); +// Delete the account +await accountToDelete.deleteAccount(accountId); // example-beneficiary.testnet +console.log(`Account ${deleteMe} was deleted`); diff --git a/javascript/examples/deploy-contract.js b/javascript/examples/deploy-contract.js new file mode 100644 index 0000000..543db1d --- /dev/null +++ b/javascript/examples/deploy-contract.js @@ -0,0 +1,28 @@ +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; + +import dotenv from "dotenv"; +import fs from "fs"; + +dotenv.config({ path: "../.env" }); + +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); + +// Create a signer from a private key string +const privateKey = process.env.PRIVATE_KEY; +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... + +// Create an account object +const accountId = process.env.ACCOUNT_ID; +const account = new Account(accountId, provider, signer); // example-account.testnet + +// Deploy a contract to the account +const result = await account.deployContract( + fs.readFileSync("../contracts/contract.wasm") // Path of contract WASM relative to the working directory +); + +console.log(result); diff --git a/javascript/examples/keys.js b/javascript/examples/keys.js index e727e01..8b7393f 100644 --- a/javascript/examples/keys.js +++ b/javascript/examples/keys.js @@ -1,53 +1,58 @@ -import { connect, keyStores, KeyPair, utils } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { KeyPair } from "@near-js/crypto"; +import { NEAR } from "@near-js/tokens"; + import dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -const privateKey = process.env.PRIVATE_KEY; + const accountId = process.env.ACCOUNT_ID; -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(privateKey); -await myKeyStore.setKey("testnet", accountId, keyPair); +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); +// Query keys with the provider +const keysProvider = await provider.viewAccessKeyList(accountId); +console.log(keysProvider); -const account = await nearConnection.account(accountId); +// Create an Account object without a signer +const account = new Account(accountId, provider); -// Get all access keys for the account -const accessKeys = await account.getAccessKeys(); +// Query keys +const accessKeys = await account.getAccessKeyList(); console.log(accessKeys); + +// Create a signer and add it to the Account +const privateKey = process.env.PRIVATE_KEY; +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... + +account.setSigner(signer); + // Add full access key -// Generate a new key pair -const newFullKeyPair = KeyPair.fromRandom("ed25519"); -const newFullPublicKey = newFullKeyPair.getPublicKey().toString(); -console.log(newFullPublicKey); +const fullKeyPair = KeyPair.fromRandom("ed25519"); -const addFullKeyResult = await account.addKey( - newFullPublicKey, // The new public key ed25519:2ASWc... +await account.addFullAccessKey( + fullKeyPair.getPublicKey().toString() // ed25519:2ASWc... ); -console.log(addFullKeyResult); +console.log(`Added FAK ${fullKeyPair.toString()}`); // Add function call access key -// Generate a new key pair -const newFunctionKeyPair = KeyPair.fromRandom("ed25519"); -const newFunctionPublicKey = newFunctionKeyPair.getPublicKey().toString(); -console.log(newFunctionPublicKey); +const fnKeyPair = KeyPair.fromRandom("ed25519"); -const addFunctionKeyResult = await account.addKey( - newFunctionPublicKey, // The new public key ed25519:2ASWc... +await account.addFunctionCallAccessKey( + fnKeyPair.getPublicKey(), // The new public key ed25519:2ASWc... "example-contract.testnet", // Contract this key is allowed to call (optional) ["example_method"], // Methods this key is allowed to call (optional) - utils.format.parseNearAmount("0.25"), // Gas allowance key can use to call methods (optional) + NEAR.toUnits("0.25") // Gas allowance key can use to call methods (optional) ); -console.log(addFunctionKeyResult); +console.log(`Added FCK ${fnKeyPair.toString()}`); -// Delete full access key -const publicKeyToDelete = newFullPublicKey; -const deleteFullKeyResult = await account.deleteKey(publicKeyToDelete); // The public key being deleted ed25519:2ASWc... -console.log(deleteFullKeyResult); +// Use the new FullAccess Key to delete the Function Call Key +const newSigner = KeyPairSigner.fromSecretKey(fullKeyPair.toString()); +account.setSigner(newSigner) +await account.deleteKey(fnKeyPair.getPublicKey().toString()); diff --git a/javascript/examples/keystore-options/credentials-directory.js b/javascript/examples/keystore-options/credentials-directory.js index 029864f..dd48e5e 100644 --- a/javascript/examples/keystore-options/credentials-directory.js +++ b/javascript/examples/keystore-options/credentials-directory.js @@ -1,31 +1,42 @@ -import { connect, keyStores, utils } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { UnencryptedFileSystemKeyStore } from "@near-js/keystores-node"; +import { NearToken } from "@near-js/tokens"; + +const NEAR = new NearToken(); + import dotenv from "dotenv"; import { homedir } from "os"; import path from "path"; // Load environment variables dotenv.config({ path: "../.env" }); -const accountId = process.env.ACCOUNT_ID; -// Create a keystore and add the key pair via credentials directory +// Create a keystore that stores keys in the `~/.near-credentials` const credentialsDirectory = ".near-credentials"; const credentialsPath = path.join(homedir(), credentialsDirectory); -const myKeyStore = new keyStores.UnencryptedFileSystemKeyStore(credentialsPath); +const myKeyStore = new UnencryptedFileSystemKeyStore(credentialsPath); -// Create a connection to the NEAR testnet -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); +const accountId = process.env.ACCOUNT_ID; -// Create an account object -const account = await nearConnection.account(accountId); // example-account.testnet +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); + +// Get the key from the keystore +const keyPair = await myKeyStore.getKey("testnet", accountId); +const signer = new KeyPairSigner(keyPair); + +// Instantiate the account +const account = new Account(accountId, provider, signer); // Test the signer by transferring NEAR -const sendTokensResult = await account.sendMoney( - "receiver-account.testnet", - utils.format.parseNearAmount("1"), +const sendTokensResult = await account.transferToken( + NEAR, + NEAR.toUnits("0.1"), + "receiver-account.testnet" ); + console.log(sendTokensResult); diff --git a/javascript/examples/keystore-options/credentials-file.js b/javascript/examples/keystore-options/credentials-file.js index 42f965c..2ac9abf 100644 --- a/javascript/examples/keystore-options/credentials-file.js +++ b/javascript/examples/keystore-options/credentials-file.js @@ -1,34 +1,37 @@ -import { connect, keyStores, KeyPair, utils } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { NearToken } from "@near-js/tokens"; + +const NEAR = new NearToken(); + import dotenv from "dotenv"; import fs from "fs"; // Load environment variables dotenv.config({ path: "../.env" }); -const accountId = process.env.ACCOUNT_ID; // Fetch the private key from a credentials file const credentialsPath = "../credentials-file.json"; // Path relative to the working directory const credentials = JSON.parse(fs.readFileSync(credentialsPath)); -// Create a key pair from the private key -const keyPair = KeyPair.fromString(credentials.private_key); -// Create a keystore and add the key pair -const myKeyStore = new keyStores.InMemoryKeyStore(); -myKeyStore.setKey("testnet", accountId, keyPair); - -// Create a connection to the NEAR testnet -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); - -// Create an account object -const account = await nearConnection.account(accountId); // example-account.testnet + +// Create a signer from the private key +const signer = KeyPairSigner.fromSecretKey(credentials.private_key); + +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); + +// Instantiate the account +const accountId = process.env.ACCOUNT_ID; +const account = new Account(accountId, provider, signer); // Test the signer by transferring NEAR -const sendTokensResult = await account.sendMoney( - "receiver-account.testnet", - utils.format.parseNearAmount("1"), +const sendTokensResult = await account.transferToken( + NEAR, + NEAR.toUnits("0.1"), + "receiver-account.testnet" ); + console.log(sendTokensResult); diff --git a/javascript/examples/keystore-options/private-key-string.js b/javascript/examples/keystore-options/private-key-string.js index ecfa921..dca05b3 100644 --- a/javascript/examples/keystore-options/private-key-string.js +++ b/javascript/examples/keystore-options/private-key-string.js @@ -1,30 +1,33 @@ -import { connect, keyStores, KeyPair, utils } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { NearToken } from "@near-js/tokens"; + +const NEAR = new NearToken(); + import dotenv from "dotenv"; // Load environment variables dotenv.config({ path: "../.env" }); -const privateKey = process.env.PRIVATE_KEY; -const accountId = process.env.ACCOUNT_ID; -// Create a keystore and add the key pair via a private key string -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(privateKey); // ed25519:5Fg2... -await myKeyStore.setKey("testnet", accountId, keyPair); +// Create a signer from a private key string +const privateKey = process.env.PRIVATE_KEY; +const signer = KeyPairSigner.fromSecretKey(privateKey); -// Create a connection to NEAR testnet -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); -// Create an account object -const account = await nearConnection.account(accountId); // example-account.testnet +// Instantiate an account +const accountId = process.env.ACCOUNT_ID; +const account = new Account(accountId, provider, signer); // Test the signer by transferring NEAR -const sendTokensResult = await account.sendMoney( - "receiver-account.testnet", - utils.format.parseNearAmount("1"), +const sendTokensResult = await account.transferToken( + NEAR, + NEAR.toUnits("0.1"), + "receiver-account.testnet" ); + console.log(sendTokensResult); diff --git a/javascript/examples/keystore-options/seed-phrase.js b/javascript/examples/keystore-options/seed-phrase.js index cdd78ec..0145318 100644 --- a/javascript/examples/keystore-options/seed-phrase.js +++ b/javascript/examples/keystore-options/seed-phrase.js @@ -1,32 +1,37 @@ -import { connect, keyStores, KeyPair, utils } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { parseNearAmount } from "@near-js/utils"; import { parseSeedPhrase } from "near-seed-phrase"; import dotenv from "dotenv"; +import { NearToken } from "@near-js/tokens"; + +const NEAR = new NearToken(); // Load environment variables dotenv.config({ path: "../.env" }); -const seedPhrase = process.env.SEED_PHRASE; -const accountId = process.env.ACCOUNT_ID; // Create a keystore and add the key pair via a seed phrase -const { secretKey } = parseSeedPhrase(seedPhrase); // "royal success river ..." -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(secretKey); // ed25519::5Fg2... -await myKeyStore.setKey("testnet", accountId, keyPair); - -// Create a connection to NEAR testnet -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); +const seedPhrase = process.env.SEED_PHRASE; // "royal success river ..." +const { secretKey } = parseSeedPhrase(seedPhrase); + +// Create a signer from a private key string +const signer = KeyPairSigner.fromSecretKey(secretKey); + +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); // Create an account object -const account = await nearConnection.account(accountId); // example-account.testnet +const accountId = process.env.ACCOUNT_ID; +const account = new Account(accountId, provider, signer); // Test the signer by transferring NEAR -const sendTokensResult = await account.sendMoney( - "receiver-account.testnet", - utils.format.parseNearAmount("1"), +const sendTokensResult = await account.transferToken( + NEAR, + NEAR.toUnits("0.1"), + "receiver-account.testnet" ); + console.log(sendTokensResult); diff --git a/javascript/examples/manual-sign.js b/javascript/examples/manual-sign.js index 5d7874e..ffa41f0 100644 --- a/javascript/examples/manual-sign.js +++ b/javascript/examples/manual-sign.js @@ -1,61 +1,77 @@ -import { KeyPair, transactions, providers, utils } from "near-api-js"; -import sha256 from "js-sha256"; +import { JsonRpcProvider } from "@near-js/providers"; +import { Account } from "@near-js/accounts"; +import { KeyPairSigner } from "@near-js/signers"; +import { actionCreators, createTransaction } from "@near-js/transactions"; +import { baseDecode } from "@near-js/utils"; +import { NEAR } from "@near-js/tokens"; + import dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -const privateKey = process.env.PRIVATE_KEY; -const accountId = process.env.ACCOUNT_ID; -const keyPair = KeyPair.fromString(privateKey); +const accountId = process.env.ACCOUNT_ID; -const provider = new providers.JsonRpcProvider({ +// Create a provider for testnet RPC +const provider = new JsonRpcProvider({ url: "https://test.rpc.fastnear.com", }); -// Get the nonce of the key -const accessKey = await provider.query( - `access_key/${accountId}/${keyPair.getPublicKey().toString()}`, - "", -); +// Assume there is a signer that will sign the transaction +const privateKey = process.env.PRIVATE_KEY; +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... + +// We only need to know the public key of the signer +const signerPublicKey = await signer.getPublicKey(); + +// We create a transaction manually + +// 1. Get the nonce of the key +const accessKey = await provider.viewAccessKey(accountId, signerPublicKey); const nonce = ++accessKey.nonce; -// Get a recent block hash -const recentBlockHash = utils.serialize.base_decode(accessKey.block_hash); +// 2. Get a recent block hash +const recentBlockHash = baseDecode(accessKey.block_hash); -// Construct actions -const actions = [transactions.transfer(utils.format.parseNearAmount("1"))]; +// 3. Construct the transaction +const actions = [actionCreators.transfer(NEAR.toUnits("0.1"))]; -// Construct transaction -const transaction = transactions.createTransaction( +const transaction = createTransaction( accountId, - keyPair.getPublicKey(), + signerPublicKey, "receiver-account.testnet", nonce, actions, - recentBlockHash, -); - -// Serialize transaction -const serializedTx = utils.serialize.serialize( - transactions.SCHEMA.Transaction, - transaction, + recentBlockHash ); -// Get serialized transaction hash -const serializedTxHash = new Uint8Array(sha256.sha256.array(serializedTx)); - -// Get signature -const signature = keyPair.sign(serializedTxHash); - -// Construct signed transaction -const signedTransaction = new transactions.SignedTransaction({ - transaction, - signature: new transactions.Signature({ - keyType: transaction.publicKey.keyType, - data: signature.signature, - }), -}); +// Sign and send +const [txHash, signedTransaction] = await signer.signTransaction(transaction); +console.log(Buffer.from(txHash).toString("hex")); // Send transaction const sendTransactionResult = await provider.sendTransaction(signedTransaction); console.log(sendTransactionResult); + + +/** + * We can also simply instantiate an account object (that does not require a signer) + * and use let it construct the transaction for us. + */ + +// 1. Instantiate account +const account = new Account(accountId, provider); + +// 2. Create transaction +const transaction2 = await account.createTransaction( + "receiver-account.testnet", + actions, + signerPublicKey +) + +// 3. Sign transaction +const [txHash2, signedTransaction2] = await signer.signTransaction(transaction2); +console.log(Buffer.from(txHash2).toString("hex")); + +// 4. Send transaction +const sendTransactionResult2 = await provider.sendTransaction(signedTransaction2); +console.log(sendTransactionResult2); diff --git a/javascript/examples/rpc-failover.js b/javascript/examples/rpc-failover.js index af2189e..21eb60b 100644 --- a/javascript/examples/rpc-failover.js +++ b/javascript/examples/rpc-failover.js @@ -1,43 +1,41 @@ -import { connect, keyStores, KeyPair, utils, providers } from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider, FailoverRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { NEAR } from "@near-js/tokens"; + import dotenv from "dotenv"; dotenv.config({ path: "../.env" }); -const privateKey = process.env.PRIVATE_KEY; -const accountId = process.env.ACCOUNT_ID; -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(privateKey); -await myKeyStore.setKey("testnet", accountId, keyPair); +// Create a signer from a private key string +const privateKey = process.env.PRIVATE_KEY; +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... // Set up a new FailoverRpcProvider with two JSON RPC providers const jsonProviders = [ - new providers.JsonRpcProvider( + new JsonRpcProvider({ url: "https://incorrect-rpc-url.com" }), // Incorrect RPC URL + new JsonRpcProvider( { url: "https://test.rpc.fastnear.com" }, // RPC URL { retries: 3, // Number of retries before giving up on a request backoff: 2, // Backoff factor for the retry delay wait: 500, // Wait time between retries in milliseconds - }, // Retry options + } // Retry options ), - new providers.JsonRpcProvider({ - url: "https://test.rpc.fastnear.com", - }), // Second RPC URL ]; -const provider = new providers.FailoverRpcProvider(jsonProviders); // Create a FailoverRpcProvider -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://incorrect-rpc-url.com", // Incorrect RPC URL - provider: provider, -}; -const nearConnection = await connect(connectionConfig); +const provider = new FailoverRpcProvider(jsonProviders); // Create a FailoverRpcProvider -const account = await nearConnection.account(accountId); +// Create an account object +const accountId = process.env.ACCOUNT_ID; +const account = new Account(accountId, provider, signer); // example-account.testnet // Test the signer with transferring 1 NEAR -const sendTokensResult = await account.sendMoney( - "receiver-account.testnet", - utils.format.parseNearAmount("1"), +const sendTokensResult = await account.transfer( + { + token: NEAR, + amount: NEAR.toUnits("0.1"), // Amount of NEAR being sent + receiverId: "receiver-account.testnet", // Receiver account ID + } ); console.log(sendTokensResult); diff --git a/javascript/examples/send-tokens.js b/javascript/examples/send-tokens.js index bf7bc64..4ad6e0a 100644 --- a/javascript/examples/send-tokens.js +++ b/javascript/examples/send-tokens.js @@ -1,31 +1,69 @@ -import * as nearAPI from "near-api-js"; +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { FungibleToken, NEAR } from "@near-js/tokens"; +import { USDT } from "@near-js/tokens/testnet"; + import dotenv from "dotenv"; -const { connect, keyStores, KeyPair, utils } = nearAPI; +const REF = new FungibleToken("ref.fakes.testnet", { + decimals: 18, + symbol: "REF", +}); // Load environment variables dotenv.config({ path: "../.env" }); // Path relative to the working directory const privateKey = process.env.PRIVATE_KEY; const accountId = process.env.ACCOUNT_ID; -// Create a keystore and add the key pair via the private key string -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(privateKey); -await myKeyStore.setKey("testnet", accountId, keyPair); - -// Create a connection to the NEAR testnet -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); - -const account = await nearConnection.account(accountId); - -// Send NEAR tokens to another account -const sendTokensResult = await account.sendMoney( - "receiver-account.testnet", // Receiver account - utils.format.parseNearAmount("1"), // Amount being sent in yoctoNEAR +// Create a signer from a private key string +const signer = KeyPairSigner.fromSecretKey(privateKey); // ed25519:5Fg2... + +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); + +// Create an account object +const account = new Account(accountId, provider, signer); // example-account.testnet + +// ------- Send NEAR tokens to another account ------- +const sendNearTokensResult = await account.transfer( + { + token: NEAR, + amount: NEAR.toUnits("0.1"), + receiverId: "receiver-account.testnet" + } +); +console.log(sendNearTokensResult); + +// ------- Send USDT tokens to another account ------- +// if a user isn't registered, the transfer will fail +// it a user is already registered, we'll just get funds back +await USDT.registerAccount({ + accountIdToRegister: "receiver-account.testnet", + fundingAccount: account, +}) + +// Use https://testnet.rhea.finance/#near|usdtt.fakes.testnet to get USDT token +const sendUsdtTokensResult = await account.transfer( + { + token: USDT, + amount: USDT.toUnits("1"), // Amount of USDT being sent + receiverId: "receiver-account.testnet" + } ); -console.log(sendTokensResult); +console.log(sendUsdtTokensResult); + +// ------- Send REF tokens to another account ------- +// Use https://testnet.rhea.finance/#near|ref.fakes.testnet to get REF tokens +const sendREFsResult = await account.transfer( + { + token: REF, + amount: REF.toUnits("1"), // Amount of REF tokens being sent + receiverId: "receiver-account.testnet" + } +); + +// we haven't registered a receiver before sending, so it may fail +console.log(sendREFsResult); diff --git a/javascript/examples/simultaneous-transactions.js b/javascript/examples/simultaneous-transactions.js index 160ff57..e371439 100644 --- a/javascript/examples/simultaneous-transactions.js +++ b/javascript/examples/simultaneous-transactions.js @@ -1,50 +1,67 @@ -import { connect, keyStores, KeyPair, transactions } from "near-api-js"; +import { JsonRpcProvider } from "@near-js/providers"; +import { KeyPairSigner } from "@near-js/signers"; +import { actionCreators, createTransaction } from "@near-js/transactions"; +import { baseDecode } from "@near-js/utils"; + import dotenv from "dotenv"; dotenv.config({ path: "../.env" }); const privateKey = process.env.PRIVATE_KEY; const accountId = process.env.ACCOUNT_ID; -const myKeyStore = new keyStores.InMemoryKeyStore(); -const keyPair = KeyPair.fromString(privateKey); -await myKeyStore.setKey("testnet", accountId, keyPair); - -const connectionConfig = { - networkId: "testnet", - keyStore: myKeyStore, - nodeUrl: "https://test.rpc.fastnear.com", -}; -const nearConnection = await connect(connectionConfig); - -const account = await nearConnection.account(accountId); - -// Send independent transactions simultaneously to different receivers -// Prepare the transactions -const args = Buffer.from(JSON.stringify({ text: "Hello, world!" })); -const tx1 = account.signAndSendTransaction({ - receiverId: "guestbook.near-examples.testnet", - actions: [ - transactions.functionCall( - "add_message", // Method name - args, // Arguments - 100000000000000, // Gas - 0, // Deposit - ), - ], -}); +// Create a signer from a private key string +const signer = KeyPairSigner.fromSecretKey(privateKey); +const signerPublicKey = await signer.getPublicKey(); -const tx2 = account.signAndSendTransaction({ - receiverId: "counter.near-examples.testnet", - actions: [ - transactions.functionCall( - "increment", // Method name - [], // Arguments - 100000000000000, // Gas - 0, // Deposit - ), - ], +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", }); -// Send the transactions simultaneously +// 1. Get information about the access key +const accessKey = await provider.viewAccessKey(accountId, signerPublicKey); + +// 2. Get a recent block hash +const recentBlockHash = baseDecode(accessKey.block_hash); + +// 3. Construct the transactions +let actions = [actionCreators.functionCall("add_message", { text: "Hello, world!" }, "30000000000000", 0)]; + +let nonce = ++accessKey.nonce; + +const addMessage = createTransaction( + accountId, + signerPublicKey, + "guestbook.near-examples.testnet", + nonce, + actions, + recentBlockHash +); + +// increment nonce so there are no collisions +nonce = nonce + 1n; + +actions = [actionCreators.functionCall("increment", {}, "30000000000000", 0)] +const increment = createTransaction( + accountId, + signerPublicKey, + "counter.near-examples.testnet", + nonce, + actions, + recentBlockHash +); + +// 4. Sign the transactions +const [txHash1, signedTransaction1] = await signer.signTransaction(addMessage); +const [txHash2, signedTransaction2] = await signer.signTransaction(increment); + +console.log(Buffer.from(txHash1).toString("hex")); +console.log(Buffer.from(txHash2).toString("hex")); + +// 5. Send the transactions +const tx1 = provider.sendTransaction(signedTransaction1); +const tx2 = provider.sendTransaction(signedTransaction2); + +// Wait for them to finish const transactionsResults = await Promise.all([tx1, tx2]); console.log(transactionsResults); diff --git a/javascript/examples/tokens-balance.js b/javascript/examples/tokens-balance.js new file mode 100644 index 0000000..2ffe6ef --- /dev/null +++ b/javascript/examples/tokens-balance.js @@ -0,0 +1,38 @@ +import { Account } from "@near-js/accounts"; +import { JsonRpcProvider } from "@near-js/providers"; +import { FungibleToken, NEAR } from "@near-js/tokens"; +import { USDT } from "@near-js/tokens/testnet"; + +import dotenv from "dotenv"; + +const REF = new FungibleToken("ref.fakes.testnet", { + decimals: 18, + symbol: "REF", +}); + +// Load environment variables +dotenv.config({ path: "../.env" }); // Path relative to the working directory +const accountId = process.env.ACCOUNT_ID; + +// Create a connection to testnet RPC +const provider = new JsonRpcProvider({ + url: "https://test.rpc.fastnear.com", +}); + +// Create an account object +const account = new Account(accountId, provider); + +// ------- Fetch NEAR tokens balance in the smallest units as BigInt ------- +const nearTokensBalanceInt = await account.getBalance(NEAR); +console.log("NEAR as units: ", nearTokensBalanceInt); +console.log("NEAR: ", NEAR.toDecimal(nearTokensBalanceInt)); + +// ------- Fetch USDT tokens balance in the smallest units as BigInt ------- +const usdtTokensBalanceInt = await account.getBalance(USDT); +console.log("USDT as units: ", usdtTokensBalanceInt); +console.log("USDT: ", USDT.toDecimal(usdtTokensBalanceInt)); + +// ------- Fetch REF tokens balance in the smallest units as BigInt ------- +const refTokensBalanceInt = await account.getBalance(REF); +console.log("REF as units: ", refTokensBalanceInt); +console.log("REF: ", REF.toDecimal(refTokensBalanceInt)); diff --git a/javascript/examples/utils.js b/javascript/examples/utils.js index 81c5704..015d6a6 100644 --- a/javascript/examples/utils.js +++ b/javascript/examples/utils.js @@ -1,9 +1,18 @@ -import { utils } from "near-api-js"; +import { USDT } from "@near-js/tokens/testnet"; +import { NEAR } from "@near-js/tokens"; // Convert NEAR amount into yoctoNEAR -const amountInYoctoNear = utils.format.parseNearAmount("1"); +const amountInYoctoNear = NEAR.toUnits("0.1"); console.log(amountInYoctoNear); // Convert yoctoNEAR amount into NEAR -const amountInNear = utils.format.formatNearAmount("1000000000000000000000000"); +const amountInNear = NEAR.toDecimal("1000000000000000000000000"); console.log(amountInNear); + +// convert USDT amount into base units +const amountInUsdtUnits = USDT.toUnits("0.1").toString(); +console.log(amountInUsdtUnits); + +// convert base units into USDT +const amountInUsdt = USDT.toDecimal("12300000"); +console.log(amountInUsdt); diff --git a/javascript/examples/verify-signature/authentication.js b/javascript/examples/verify-signature/authentication.js index b45ce5a..dc15f1a 100644 --- a/javascript/examples/verify-signature/authentication.js +++ b/javascript/examples/verify-signature/authentication.js @@ -1,5 +1,5 @@ import * as borsh from 'borsh'; -import * as naj from 'near-api-js'; +import { PublicKey } from '@near-js/crypto'; import js_sha256 from 'js-sha256'; class Payload { @@ -33,7 +33,7 @@ function verifySignature({ publicKey, signature, message, recipient, nonce }) { let real_signature = Buffer.from(signature, 'base64') // Use the public Key to verify that the private-counterpart signed the message - const myPK = naj.utils.PublicKey.from(publicKey) + const myPK = PublicKey.from(publicKey) return myPK.verify(to_sign, real_signature) } diff --git a/javascript/package.json b/javascript/package.json index 535b14e..06e31ef 100644 --- a/javascript/package.json +++ b/javascript/package.json @@ -1,29 +1,51 @@ { "type": "module", "dependencies": { + "@near-js/accounts": "link:../../near-api-js/packages/accounts", + "@near-js/crypto": "link:../../near-api-js/packages/crypto", + "@near-js/keystores-node": "link:../../near-api-js/packages/keystores-node", + "@near-js/providers": "link:../../near-api-js/packages/providers", + "@near-js/signers": "link:../../near-api-js/packages/signers", + "@near-js/tokens": "link:../../near-api-js/packages/tokens", + "@near-js/transactions": "link:../../near-api-js/packages/transactions", + "@near-js/utils": "link:../../near-api-js/packages/utils", "borsh": "2.0.0", "dotenv": "^16.4.7", "js-sha256": "^0.11.0", - "near-api-js": "^4.0.4", "near-seed-phrase": "^0.2.1" }, "scripts": { - "credentials-directory": "node examples/keystore-options/credentials-directory.js", - "credentials-file": "node examples/keystore-options/credentials-file.js", - "private-key-string": "node examples/keystore-options/private-key-string.js", - "seed-phrase": "node examples/keystore-options/seed-phrase.js", "account-details": "node examples/account-details.js", "batch-actions": "node examples/batch-actions.js", "contract-interaction": "node examples/contract-interaction.js", "create-account-from-seed": "node examples/create-account-from-seed.js", - "create-account": "node examples/create-account.js", + "create-subaccount": "node examples/create-subaccount.js", + "create-tla": "node examples/create-tla.js", + "credentials-directory": "node examples/keystore-options/credentials-directory.js", + "credentials-file": "node examples/keystore-options/credentials-file.js", "delete-account": "node examples/delete-account.js", + "deploy-contract": "node examples/deploy-contract.js", "keys": "node examples/keys.js", "manual-sign": "node examples/manual-sign.js", + "private-key-string": "node examples/keystore-options/private-key-string.js", "rpc-failover": "node examples/rpc-failover.js", + "seed-phrase": "node examples/keystore-options/seed-phrase.js", "send-tokens": "node examples/send-tokens.js", "simultaneous-transactions": "node examples/simultaneous-transactions.js", + "tokens-balance": "node examples/tokens-balance.js", "utils": "node examples/utils.js", "verify-signature": "node examples/verify-signature/verify-signature.js" + }, + "pnpm": { + "overrides": { + "@near-js/accounts": "link:../../near-api-js/packages/accounts", + "@near-js/signers": "link:../../near-api-js/packages/signers", + "@near-js/providers": "link:../../near-api-js/packages/providers", + "@near-js/utils": "link:../../near-api-js/packages/utils", + "@near-js/transactions": "link:../../near-api-js/packages/transactions", + "@near-js/keystores-node": "link:../../near-api-js/packages/keystores-node", + "@near-js/crypto": "link:../../near-api-js/packages/crypto", + "@near-js/tokens": "link:../../near-api-js/packages/tokens" + } } } diff --git a/javascript/pnpm-lock.yaml b/javascript/pnpm-lock.yaml index 5d53a49..dc8f914 100644 --- a/javascript/pnpm-lock.yaml +++ b/javascript/pnpm-lock.yaml @@ -4,83 +4,62 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + '@near-js/accounts': link:../../near-api-js/packages/accounts + '@near-js/signers': link:../../near-api-js/packages/signers + '@near-js/providers': link:../../near-api-js/packages/providers + '@near-js/utils': link:../../near-api-js/packages/utils + '@near-js/transactions': link:../../near-api-js/packages/transactions + '@near-js/keystores-node': link:../../near-api-js/packages/keystores-node + '@near-js/crypto': link:../../near-api-js/packages/crypto + '@near-js/tokens': link:../../near-api-js/packages/tokens + importers: .: dependencies: + '@near-js/accounts': + specifier: link:../../near-api-js/packages/accounts + version: link:../../near-api-js/packages/accounts + '@near-js/crypto': + specifier: link:../../near-api-js/packages/crypto + version: link:../../near-api-js/packages/crypto + '@near-js/keystores-node': + specifier: link:../../near-api-js/packages/keystores-node + version: link:../../near-api-js/packages/keystores-node + '@near-js/providers': + specifier: link:../../near-api-js/packages/providers + version: link:../../near-api-js/packages/providers + '@near-js/signers': + specifier: link:../../near-api-js/packages/signers + version: link:../../near-api-js/packages/signers + '@near-js/tokens': + specifier: link:../../near-api-js/packages/tokens + version: link:../../near-api-js/packages/tokens + '@near-js/transactions': + specifier: link:../../near-api-js/packages/transactions + version: link:../../near-api-js/packages/transactions + '@near-js/utils': + specifier: link:../../near-api-js/packages/utils + version: link:../../near-api-js/packages/utils borsh: - specifier: 1.0.0 - version: 1.0.0 + specifier: 2.0.0 + version: 2.0.0 dotenv: specifier: ^16.4.7 version: 16.4.7 js-sha256: specifier: ^0.11.0 version: 0.11.0 - near-api-js: - specifier: ^4.0.4 - version: 4.0.4 near-seed-phrase: specifier: ^0.2.1 version: 0.2.1 packages: - '@near-js/accounts@1.2.2': - resolution: {integrity: sha512-8XInUVl8WwQyitRkG1HffZKhDmAXUwOaxurgkTYocDUUUp+ZB8NPxidg2uvj6f2wqnC8KAkjpm73wPoyRm6+yQ==} - - '@near-js/crypto@1.3.0': - resolution: {integrity: sha512-BIKO6v+rbYCzzrjsSV4KgClVgRiPluIXQ89B4ozIG8RjjBe/7IPFYF9tIxsXUyLzPFhISzeNQkL09ksHHmnymg==} - - '@near-js/keystores-browser@0.1.0': - resolution: {integrity: sha512-v/4uFHKnbEXY4UcOAVCUSb3GKsVdrwv4uXBSPluvE16H9oxjB1+gfcz5qejwKp2cifYNCO0KfAWLnZas66Ohcg==} - - '@near-js/keystores-node@0.0.13': - resolution: {integrity: sha512-cnk2mwIRr7bCPgqz7KHU1Bqxm0u9J+FIubZ0AllFpMVMv8TJVVbs7FcsVIk282oeM7xxikjVJjs35DG6//Fehw==} - - '@near-js/keystores@0.1.0': - resolution: {integrity: sha512-89EwYFDvPg7GnJAKmBDASKUSTXny0ZqgqDnSdhp7oJ78bXNlCs9xx0WnkK34TxFBnrL4c9szLjTkfGRcFT07NQ==} - - '@near-js/providers@0.2.3': - resolution: {integrity: sha512-JBSze9fdoRXkOsFeLiooPWGm3vemY2dgHT0u0HoJCjpQtt41v7tr+6sWpxGWCaDwrzIwhm7og4qkGv4K9IxFVw==} - - '@near-js/signers@0.1.5': - resolution: {integrity: sha512-UldCktmR6HF6N2gPbgiUS8QPYCcDwjyzpdi3ukKezfY2NGA++F068ZwP50S+aQrtcwEBpECTo/Ps6pZq7cSVeQ==} - - '@near-js/transactions@1.2.3': - resolution: {integrity: sha512-wwkUupWrmKfdZmv6TmnTrskysX37F2SVHcns6BVwPjp6nFD29NAhul71I6u++8496Lq2FrgM1Kb8pEIpG9TV9w==} - - '@near-js/types@0.2.1': - resolution: {integrity: sha512-YygQEGMdFe6d2e/6dtNZer9paH396XeAdIKEhY/RPXDUnjDdfiDQ5DK4mM130sEeID2bAH9X1LQ+7vXGRjvyWw==} - - '@near-js/utils@0.3.0': - resolution: {integrity: sha512-ExeWqP0b4subLcQuLDIixAZs6tiCWifDBz2OwU9ycntyjZslUUh4EKBaSS3mAEqhJ/t1B9WX80BntE/5PQ+JTg==} - - '@near-js/wallet-account@1.2.3': - resolution: {integrity: sha512-yuYKKA8D06ztmbTvbajD8HBjP50x2NbMRPInsSSgNjBnvFA9f2J82SarzDLg+nTsayhMJdFGfArnKgIlO+bUaw==} - - '@noble/curves@1.2.0': - resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} - - '@noble/hashes@1.3.2': - resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} - engines: {node: '>= 16'} - - '@noble/hashes@1.3.3': - resolution: {integrity: sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==} - engines: {node: '>= 16'} - - '@types/json-schema@7.0.15': - resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} - '@types/node@11.11.6': resolution: {integrity: sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ==} - base-x@2.0.6: - resolution: {integrity: sha512-UAmjxz9KbK+YIi66xej+pZVo/vxUOh49ubEvZW5egCbxhur05pBb+hwuireQwKO4nDpsNm64/jEei17LEpsr5g==} - engines: {node: '>=4.5.0'} - deprecated: use 3.0.0 instead, safe-buffer has been merged and release for compatability - base-x@3.0.10: resolution: {integrity: sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ==} @@ -90,17 +69,8 @@ packages: bip39@3.0.2: resolution: {integrity: sha512-J4E1r2N0tUylTKt07ibXvhpT2c5pyAFgvuA5q1H9uDy6dEGpjV8jmymh3MTYJDLCNbIVClSB9FbND49I6N24MQ==} - bn.js@4.12.1: - resolution: {integrity: sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==} - - borsh@1.0.0: - resolution: {integrity: sha512-fSVWzzemnyfF89EPwlUNsrS5swF5CrtiN4e+h0/lLf4dz2he4L3ndM20PS9wj7ICSkXJe/TQUHdaPTq15b1mNQ==} - - brorand@1.1.0: - resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} - - bs58@4.0.0: - resolution: {integrity: sha512-/jcGuUuSebyxwLLfKrbKnCJttxRf9PM51EnHTwmFKBxl4z1SGkoAhrfd6uZKE0dcjQTfm6XzTP8DPr1tzE4KIw==} + borsh@2.0.0: + resolution: {integrity: sha512-kc9+BgR3zz9+cjbwM8ODoUB4fs3X3I5A/HtX7LZKxCLaMrEeDFoBpnhZY//DTS1VZBSs6S5v46RZRbZjRFspEg==} bs58@4.0.1: resolution: {integrity: sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==} @@ -115,108 +85,29 @@ packages: create-hmac@1.1.7: resolution: {integrity: sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==} - depd@1.1.2: - resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==} - engines: {node: '>= 0.6'} - - depd@2.0.0: - resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} - engines: {node: '>= 0.8'} - dotenv@16.4.7: resolution: {integrity: sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==} engines: {node: '>=12'} - elliptic@6.6.1: - resolution: {integrity: sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g==} - - generate-function@2.3.1: - resolution: {integrity: sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==} - - generate-object-property@1.2.0: - resolution: {integrity: sha512-TuOwZWgJ2VAMEGJvAyPWvpqxSANF0LDpmyHauMjFYzaACvn+QTT/AZomvPCzVBV7yDN3OmwHQ5OvHaeLKre3JQ==} - hash-base@3.1.0: resolution: {integrity: sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==} engines: {node: '>=4'} - hash.js@1.1.7: - resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==} - - hmac-drbg@1.0.1: - resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} - - http-errors@1.7.2: - resolution: {integrity: sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==} - engines: {node: '>= 0.6'} - - inherits@2.0.3: - resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} - inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - is-my-ip-valid@1.0.1: - resolution: {integrity: sha512-jxc8cBcOWbNK2i2aTkCZP6i7wkHF1bqKFrwEHuN5Jtg5BSaZHUZQ/JTOJwoV41YvHnOaRyWWh72T/KvfNz9DJg==} - - is-my-json-valid@2.20.6: - resolution: {integrity: sha512-1JQwulVNjx8UqkPE/bqDaxtH4PXCe/2VRh/y3p99heOV87HG4Id5/VfDswd+YiAfHcRTfDlWgISycnHuhZq1aw==} - - is-property@1.0.2: - resolution: {integrity: sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==} - js-sha256@0.11.0: resolution: {integrity: sha512-6xNlKayMZvds9h1Y1VWc0fQHQ82BxTXizWPEtEeGvmOUYpBRy4gbWroHLpzowe6xiQhHpelCQiE7HEdznyBL9Q==} - jsonpointer@5.0.1: - resolution: {integrity: sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==} - engines: {node: '>=0.10.0'} - - lru_map@0.4.1: - resolution: {integrity: sha512-I+lBvqMMFfqaV8CJCISjI3wbjmwVu/VyOoU7+qtu9d7ioW5klMgsTTiUOUp+DJvfTTzKXoPbyC6YfgkNcyPSOg==} - md5.js@1.3.5: resolution: {integrity: sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==} - minimalistic-assert@1.0.1: - resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} - - minimalistic-crypto-utils@1.0.1: - resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} - - mustache@4.0.0: - resolution: {integrity: sha512-FJgjyX/IVkbXBXYUwH+OYwQKqWpFPLaLVESd70yHjSDunwzV2hZOoTBvPf4KLoxesUzzyfTH6F784Uqd7Wm5yA==} - engines: {npm: '>=1.4.0'} - hasBin: true - - near-abi@0.1.1: - resolution: {integrity: sha512-RVDI8O+KVxRpC3KycJ1bpfVj9Zv+xvq9PlW1yIFl46GhrnLw83/72HqHGjGDjQ8DtltkcpSjY9X3YIGZ+1QyzQ==} - - near-api-js@4.0.4: - resolution: {integrity: sha512-IG+6NAMtn854palu/cIbVgey0OsIzllcajc3fbEbh7cb2pyPNMsfsBIO5WqsV+rY+7Tqr6lqYQ8f+4BHGUttyg==} - near-hd-key@1.2.1: resolution: {integrity: sha512-SIrthcL5Wc0sps+2e1xGj3zceEa68TgNZDLuCx0daxmfTP7sFTB3/mtE2pYhlFsCxWoMn+JfID5E1NlzvvbRJg==} near-seed-phrase@0.2.1: resolution: {integrity: sha512-feMuums+kVL3LSuPcP4ld07xHCb2mu6z48SGfP3W+8tl1Qm5xIcjiQzY2IDPBvFgajRDxWSb8GzsRHoInazByw==} - node-addon-api@5.1.0: - resolution: {integrity: sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==} - - node-fetch@2.6.7: - resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} - engines: {node: 4.x || >=6.0.0} - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - - node-gyp-build@4.8.4: - resolution: {integrity: sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==} - hasBin: true - pbkdf2@3.1.2: resolution: {integrity: sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==} engines: {node: '>=0.12'} @@ -234,155 +125,23 @@ packages: safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - secp256k1@5.0.0: - resolution: {integrity: sha512-TKWX8xvoGHrxVdqbYeZM9w+izTF4b9z3NhSaDkdn81btvuh+ivbIMGT/zQvDtTFWhRlThpoz6LEYTr7n8A5GcA==} - engines: {node: '>=14.0.0'} - - setprototypeof@1.1.1: - resolution: {integrity: sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==} - sha.js@2.4.11: resolution: {integrity: sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==} hasBin: true - statuses@1.5.0: - resolution: {integrity: sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==} - engines: {node: '>= 0.6'} - string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} - toidentifier@1.0.0: - resolution: {integrity: sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==} - engines: {node: '>=0.6'} - - tr46@0.0.3: - resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - tweetnacl@1.0.3: resolution: {integrity: sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==} util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} - webidl-conversions@3.0.1: - resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - - whatwg-url@5.0.0: - resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} - - xtend@4.0.2: - resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} - engines: {node: '>=0.4'} - snapshots: - '@near-js/accounts@1.2.2': - dependencies: - '@near-js/crypto': 1.3.0 - '@near-js/providers': 0.2.3 - '@near-js/signers': 0.1.5 - '@near-js/transactions': 1.2.3 - '@near-js/types': 0.2.1 - '@near-js/utils': 0.3.0 - borsh: 1.0.0 - depd: 2.0.0 - is-my-json-valid: 2.20.6 - lru_map: 0.4.1 - near-abi: 0.1.1 - transitivePeerDependencies: - - encoding - - '@near-js/crypto@1.3.0': - dependencies: - '@near-js/types': 0.2.1 - '@near-js/utils': 0.3.0 - '@noble/curves': 1.2.0 - borsh: 1.0.0 - randombytes: 2.1.0 - secp256k1: 5.0.0 - - '@near-js/keystores-browser@0.1.0': - dependencies: - '@near-js/crypto': 1.3.0 - '@near-js/keystores': 0.1.0 - - '@near-js/keystores-node@0.0.13': - dependencies: - '@near-js/crypto': 1.3.0 - '@near-js/keystores': 0.1.0 - - '@near-js/keystores@0.1.0': - dependencies: - '@near-js/crypto': 1.3.0 - '@near-js/types': 0.2.1 - - '@near-js/providers@0.2.3': - dependencies: - '@near-js/transactions': 1.2.3 - '@near-js/types': 0.2.1 - '@near-js/utils': 0.3.0 - borsh: 1.0.0 - http-errors: 1.7.2 - optionalDependencies: - node-fetch: 2.6.7 - transitivePeerDependencies: - - encoding - - '@near-js/signers@0.1.5': - dependencies: - '@near-js/crypto': 1.3.0 - '@near-js/keystores': 0.1.0 - '@noble/hashes': 1.3.3 - - '@near-js/transactions@1.2.3': - dependencies: - '@near-js/crypto': 1.3.0 - '@near-js/signers': 0.1.5 - '@near-js/types': 0.2.1 - '@near-js/utils': 0.3.0 - '@noble/hashes': 1.3.3 - borsh: 1.0.0 - - '@near-js/types@0.2.1': {} - - '@near-js/utils@0.3.0': - dependencies: - '@near-js/types': 0.2.1 - bs58: 4.0.0 - depd: 2.0.0 - mustache: 4.0.0 - - '@near-js/wallet-account@1.2.3': - dependencies: - '@near-js/accounts': 1.2.2 - '@near-js/crypto': 1.3.0 - '@near-js/keystores': 0.1.0 - '@near-js/providers': 0.2.3 - '@near-js/signers': 0.1.5 - '@near-js/transactions': 1.2.3 - '@near-js/types': 0.2.1 - '@near-js/utils': 0.3.0 - borsh: 1.0.0 - transitivePeerDependencies: - - encoding - - '@noble/curves@1.2.0': - dependencies: - '@noble/hashes': 1.3.2 - - '@noble/hashes@1.3.2': {} - - '@noble/hashes@1.3.3': {} - - '@types/json-schema@7.0.15': {} - '@types/node@11.11.6': {} - base-x@2.0.6: - dependencies: - safe-buffer: 5.2.1 - base-x@3.0.10: dependencies: safe-buffer: 5.2.1 @@ -399,15 +158,7 @@ snapshots: pbkdf2: 3.1.2 randombytes: 2.1.0 - bn.js@4.12.1: {} - - borsh@1.0.0: {} - - brorand@1.1.0: {} - - bs58@4.0.0: - dependencies: - base-x: 2.0.6 + borsh@2.0.0: {} bs58@4.0.1: dependencies: @@ -435,115 +186,24 @@ snapshots: safe-buffer: 5.2.1 sha.js: 2.4.11 - depd@1.1.2: {} - - depd@2.0.0: {} - dotenv@16.4.7: {} - elliptic@6.6.1: - dependencies: - bn.js: 4.12.1 - brorand: 1.1.0 - hash.js: 1.1.7 - hmac-drbg: 1.0.1 - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - - generate-function@2.3.1: - dependencies: - is-property: 1.0.2 - - generate-object-property@1.2.0: - dependencies: - is-property: 1.0.2 - hash-base@3.1.0: dependencies: inherits: 2.0.4 readable-stream: 3.6.2 safe-buffer: 5.2.1 - hash.js@1.1.7: - dependencies: - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - - hmac-drbg@1.0.1: - dependencies: - hash.js: 1.1.7 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - - http-errors@1.7.2: - dependencies: - depd: 1.1.2 - inherits: 2.0.3 - setprototypeof: 1.1.1 - statuses: 1.5.0 - toidentifier: 1.0.0 - - inherits@2.0.3: {} - inherits@2.0.4: {} - is-my-ip-valid@1.0.1: {} - - is-my-json-valid@2.20.6: - dependencies: - generate-function: 2.3.1 - generate-object-property: 1.2.0 - is-my-ip-valid: 1.0.1 - jsonpointer: 5.0.1 - xtend: 4.0.2 - - is-property@1.0.2: {} - js-sha256@0.11.0: {} - jsonpointer@5.0.1: {} - - lru_map@0.4.1: {} - md5.js@1.3.5: dependencies: hash-base: 3.1.0 inherits: 2.0.4 safe-buffer: 5.2.1 - minimalistic-assert@1.0.1: {} - - minimalistic-crypto-utils@1.0.1: {} - - mustache@4.0.0: {} - - near-abi@0.1.1: - dependencies: - '@types/json-schema': 7.0.15 - - near-api-js@4.0.4: - dependencies: - '@near-js/accounts': 1.2.2 - '@near-js/crypto': 1.3.0 - '@near-js/keystores': 0.1.0 - '@near-js/keystores-browser': 0.1.0 - '@near-js/keystores-node': 0.0.13 - '@near-js/providers': 0.2.3 - '@near-js/signers': 0.1.5 - '@near-js/transactions': 1.2.3 - '@near-js/types': 0.2.1 - '@near-js/utils': 0.3.0 - '@near-js/wallet-account': 1.2.3 - '@noble/curves': 1.2.0 - borsh: 1.0.0 - depd: 2.0.0 - http-errors: 1.7.2 - near-abi: 0.1.1 - node-fetch: 2.6.7 - transitivePeerDependencies: - - encoding - near-hd-key@1.2.1: dependencies: bip39: 3.0.2 @@ -557,14 +217,6 @@ snapshots: near-hd-key: 1.2.1 tweetnacl: 1.0.3 - node-addon-api@5.1.0: {} - - node-fetch@2.6.7: - dependencies: - whatwg-url: 5.0.0 - - node-gyp-build@4.8.4: {} - pbkdf2@3.1.2: dependencies: create-hash: 1.2.0 @@ -590,38 +242,15 @@ snapshots: safe-buffer@5.2.1: {} - secp256k1@5.0.0: - dependencies: - elliptic: 6.6.1 - node-addon-api: 5.1.0 - node-gyp-build: 4.8.4 - - setprototypeof@1.1.1: {} - sha.js@2.4.11: dependencies: inherits: 2.0.4 safe-buffer: 5.2.1 - statuses@1.5.0: {} - string_decoder@1.3.0: dependencies: safe-buffer: 5.2.1 - toidentifier@1.0.0: {} - - tr46@0.0.3: {} - tweetnacl@1.0.3: {} util-deprecate@1.0.2: {} - - webidl-conversions@3.0.1: {} - - whatwg-url@5.0.0: - dependencies: - tr46: 0.0.3 - webidl-conversions: 3.0.1 - - xtend@4.0.2: {}