-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
335 changed files
with
38,045 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
packages/**/node_modules/ | ||
dist/** | ||
**/*.test.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
node: true, | ||
}, | ||
ignorePatterns: ["*.js", "examples/*", "src/indexer/generated/**", "scripts/publish_ans_contract.ts"], | ||
extends: ["airbnb-base", "airbnb-typescript/base", "prettier"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ["tsconfig.json"], | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
rules: { | ||
quotes: ["error", "double"], | ||
"max-len": ["error", 120], | ||
"import/extensions": ["error", "never"], | ||
"max-classes-per-file": ["error", 10], | ||
"import/prefer-default-export": "off", | ||
"object-curly-newline": "off", | ||
"no-use-before-define": "off", | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-use-before-define": ["error", { functions: false, classes: false }], | ||
"@typescript-eslint/no-unused-vars": ["error"], | ||
}, | ||
settings: { | ||
"import/resolver": { | ||
node: { | ||
extensions: [".js", ".jsx", ".ts", ".tsx"], | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.env | ||
.DS_Store | ||
*/**/.DS_Store | ||
npm-debug.log | ||
.npm/ | ||
/coverage | ||
/tmp | ||
node_modules | ||
.idea/ | ||
.history/ | ||
.vscode/ | ||
dist/ | ||
.nyc_output/ | ||
build/ | ||
|
||
# Doc generation output | ||
docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
coverage | ||
node_modules | ||
.aptos | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v16.14.0n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
src/generated/* | ||
src/indexer/generated/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"types": [ | ||
{ "type": "feat", "section": "Features" }, | ||
{ "type": "fix", "section": "Bug Fixes" }, | ||
{ "type": "chore", "hidden": true }, | ||
{ "type": "docs", "hidden": true }, | ||
{ "type": "style", "hidden": true }, | ||
{ "type": "refactor", "hidden": true }, | ||
{ "type": "perf", "hidden": true }, | ||
{ "type": "test", "hidden": true } | ||
], | ||
"skip": { | ||
"bump": true, | ||
"commit": true, | ||
"tag": true | ||
}, | ||
"path": ".", | ||
"header": "# Changelog\n\nAll notable changes to this project will be documented in this file.\n\nNote: This changelog is generated automatically.\n\n" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Contribution Guidelines for Typescript SDK | ||
|
||
- Coding Styles | ||
- File names must use Snake case. For example, `aptos_account.ts` . | ||
- Class names must use Pascal case. For example, `class AuthenticationKey` . | ||
- Function and method names must use Camel case. For example, `derivedAddress(): HexString` . | ||
- Constants must use all caps (upper case) words separated by `_`. For example, `MAX_U8_NUMBER` . | ||
- Comments | ||
- Comments are required for new classes and functions. | ||
- Comments should follow the TSDoc standard, [https://tsdoc.org/](https://tsdoc.org/). | ||
- Lints and Formats | ||
- ESlint (eslint) and Prettier (prettier) should be used for code checking and code formatting. Make sure to run `pnpm lint` and `pnpm fmt` after making changes to the code. | ||
- Tests | ||
- Unit tests are required for any non-trivial changes you make. | ||
- The Jest testing framework is used in the repo and we recommend you use it. See Jest: [https://jestjs.io/](https://jestjs.io/). | ||
- Make sure to run `pnpm test` after making changes. | ||
- Commits | ||
- Commit messages follow the [Angular convention](https://www.conventionalcommits.org/en/v1.0.0-beta.4/#summary). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# SDK for Movement Node API | ||
|
||
## Quickstart | ||
|
||
The public SDK downloaded from [npmjs](https://www.npmjs.com/package/movement-sdk) is compatible with the [movement testnet](https://seed-node1.movementlabs.xyz). To start building, run below command in your project directory: | ||
|
||
```bash | ||
pnpm add movement-sdk | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
**NOTE**: These examples are tested to work with the [latest SDK published to npmjs](https://www.npmjs.com/package/aptos), not the SDK in the parent directory. Accordingly, these examples should be run against devnet. This is how the examples work by default. | ||
|
||
If you'd like to learn more about how these examples work, please see the following tutorials: | ||
- [Your first transaction](https://aptos.dev/tutorials/your-first-transaction-sdk) | ||
- [Your first NFT](https://aptos.dev/tutorials/your-first-nft-sdk) |
82 changes: 82 additions & 0 deletions
82
vm/aptos-vm/subnet/JavaScript-client/examples/javascript/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
require("dotenv").config(); | ||
|
||
const aptos = require("aptos"); | ||
|
||
const NODE_URL = process.env.APTOS_NODE_URL || "https://fullnode.devnet.aptoslabs.com"; | ||
const FAUCET_URL = process.env.APTOS_FAUCET_URL || "https://faucet.devnet.aptoslabs.com"; | ||
|
||
const aptosCoin = "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>"; | ||
|
||
(async () => { | ||
const client = new aptos.AptosClient(NODE_URL); | ||
const faucetClient = new aptos.FaucetClient(NODE_URL, FAUCET_URL, null); | ||
const tokenClient = new aptos.TokenClient(client); | ||
|
||
const account1 = new aptos.AptosAccount(); | ||
await faucetClient.fundAccount(account1.address(), 100_000_000); | ||
let resources = await client.getAccountResources(account1.address()); | ||
let accountResource = resources.find((r) => r.type === aptosCoin); | ||
console.log(`account1 coins: ${accountResource.data.coin.value}. Should be 100_000_000!`); | ||
|
||
const account2 = new aptos.AptosAccount(); | ||
await faucetClient.fundAccount(account2.address(), 0); | ||
resources = await client.getAccountResources(account2.address()); | ||
accountResource = resources.find((r) => r.type === aptosCoin); | ||
console.log(`account2 coins: ${accountResource.data.coin.value}. Should be 0!`); | ||
|
||
const payload = { | ||
type: "entry_function_payload", | ||
function: "0x1::coin::transfer", | ||
type_arguments: ["0x1::aptos_coin::AptosCoin"], | ||
arguments: [account2.address().hex(), 717], | ||
}; | ||
const txnRequest = await client.generateTransaction(account1.address(), payload); | ||
const signedTxn = await client.signTransaction(account1, txnRequest); | ||
const transactionRes = await client.submitTransaction(signedTxn); | ||
await client.waitForTransaction(transactionRes.hash); | ||
|
||
resources = await client.getAccountResources(account2.address()); | ||
accountResource = resources.find((r) => r.type === aptosCoin); | ||
console.log(`account2 coins: ${accountResource.data.coin.value}. Should be 717!`); | ||
|
||
const provider = new aptos.Provider(aptos.Network.DEVNET); | ||
console.log("\n=== Checking if indexer devnet chainId same as fullnode chainId ==="); | ||
const indexerLedgerInfo = await provider.getIndexerLedgerInfo(); | ||
const fullNodeChainId = await provider.getChainId(); | ||
|
||
console.log(`\n fullnode chain id is: ${fullNodeChainId}, indexer chain id is: ${indexerLedgerInfo}`); | ||
if (indexerLedgerInfo.ledger_infos[0].chain_id !== fullNodeChainId) { | ||
console.log(`\n fullnode chain id and indexer chain id are not synced, skipping rest of tests`); | ||
return; | ||
} | ||
|
||
console.log("=== Creating account1's NFT Collection and Token ==="); | ||
|
||
const collectionName = "Alice's"; | ||
const tokenName = "Alice's first token"; | ||
|
||
// Create the collection. | ||
// :!:>section_4 | ||
const txnHash1 = await tokenClient.createCollection( | ||
account1, | ||
collectionName, | ||
"Alice's simple collection", | ||
"https://alice.com", | ||
); // <:!:section_4 | ||
await client.waitForTransaction(txnHash1, { checkSuccess: true }); | ||
|
||
// Create a token in that collection. | ||
// :!:>section_5 | ||
const txnHash2 = await tokenClient.createToken( | ||
account1, | ||
collectionName, | ||
tokenName, | ||
"Alice's simple token", | ||
1, | ||
"https://aptos.dev/img/nyan.jpeg", | ||
); // <:!:section_5 | ||
await client.waitForTransaction(txnHash2, { checkSuccess: true }); | ||
|
||
const nfts = await provider.getAccountNFTs(account1.address().hex()); | ||
console.log(`account1 current token ownership: ${nfts.current_token_ownerships[0].amount}. Should be 1`); | ||
})(); |
16 changes: 16 additions & 0 deletions
16
vm/aptos-vm/subnet/JavaScript-client/examples/javascript/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "js-test", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node index.js" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"aptos": "latest", | ||
"dotenv": "16.0.2" | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
vm/aptos-vm/subnet/JavaScript-client/examples/javascript/pnpm-lock.yaml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.