@aptos-labs/ts-sdk
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -33,2 +33,16 @@ { | ||
], | ||
"scripts": { | ||
"build:clean": "rm -rf dist", | ||
"build": "pnpm build:clean && tsup", | ||
"_fmt": "prettier 'src/**/*.ts' 'tests/**/*.ts' 'examples/**/*.js' 'examples/**/*.ts' '.eslintrc.js'", | ||
"fmt": "pnpm _fmt --write", | ||
"lint": "eslint 'src/**/*.ts' 'tests/**/*.ts' 'examples/**/*.ts'", | ||
"test": "pnpm jest", | ||
"unit-test": "pnpm jest tests/unit", | ||
"e2e-test": "pnpm jest tests/e2e", | ||
"indexer-codegen": "graphql-codegen --config ./src/types/codegen.yaml && pnpm fmt", | ||
"doc": "scripts/generateDocs.sh", | ||
"check-version": "scripts/checkVersion.sh", | ||
"update-version": "scripts/updateVersion.sh && pnpm doc" | ||
}, | ||
"dependencies": { | ||
@@ -44,2 +58,3 @@ "@aptos-labs/aptos-client": "^0.1.0", | ||
"devDependencies": { | ||
"@aptos-labs/aptos-cli": "^0.1.2", | ||
"@babel/traverse": "^7.23.6", | ||
@@ -65,2 +80,3 @@ "@graphql-codegen/cli": "^5.0.0", | ||
"prettier": "^3.1.1", | ||
"tree-kill": "^1.2.2", | ||
"ts-jest": "^29.1.1", | ||
@@ -73,17 +89,3 @@ "ts-loader": "^9.5.1", | ||
}, | ||
"version": "1.2.0", | ||
"scripts": { | ||
"build:clean": "rm -rf dist", | ||
"build": "pnpm build:clean && tsup", | ||
"_fmt": "prettier 'src/**/*.ts' 'tests/**/*.ts' 'examples/**/*.js' 'examples/**/*.ts' '.eslintrc.js'", | ||
"fmt": "pnpm _fmt --write", | ||
"lint": "eslint 'src/**/*.ts' 'tests/**/*.ts' 'examples/**/*.ts'", | ||
"test": "pnpm jest", | ||
"unit-test": "pnpm jest tests/unit", | ||
"e2e-test": "pnpm jest tests/e2e", | ||
"indexer-codegen": "graphql-codegen --config ./src/types/codegen.yaml && pnpm fmt", | ||
"doc": "scripts/generateDocs.sh", | ||
"check-version": "scripts/checkVersion.sh", | ||
"update-version": "scripts/updateVersion.sh && pnpm doc" | ||
} | ||
} | ||
"version": "1.3.0" | ||
} |
@@ -86,9 +86,36 @@ # Typescript SDK for Aptos | ||
```ts | ||
const aptos = new Aptos(); | ||
// This functions resolves the provided private key type and derives the public key from it | ||
// Create a private key instance for Ed25519 scheme | ||
const privateKey = new Ed25519PrivateKey("myEd25519privatekeystring"); | ||
// Or for Secp256k1 scheme | ||
const privateKey = new Secp256k1PrivateKey("mySecp256k1privatekeystring"); | ||
// Derive an account from private key | ||
// This is used as a local calculation and therefore is used to instantiate an `Account` | ||
// that has not had its authentication key rotated | ||
const account = await Account.fromPrivateKey({ privateKey }); | ||
// Also, can use this function that resolves the provided private key type and derives the public key from it | ||
// to support key rotation and differentiation between Legacy Ed25519 and Unified authentications | ||
// Read more https://github.com/aptos-labs/aptos-ts-sdk/blob/main/src/api/account.ts#L364 | ||
const account = await aptos.deriveAccountFromPrivateKey({ privateKey: privateKey }); | ||
const aptos = new Aptos(); | ||
const account = await aptos.deriveAccountFromPrivateKey({ privateKey }); | ||
``` | ||
#### Derive from private key and address | ||
```ts | ||
// Create a private key instance for Ed25519 scheme | ||
const privateKey = new Ed25519PrivateKey("myEd25519privatekeystring"); | ||
// Or for Secp256k1 scheme | ||
const privateKey = new Secp256k1PrivateKey("mySecp256k1privatekeystring"); | ||
// Derive an account from private key and address | ||
// create an AccountAddress instance from the account address string | ||
const address = AccountAddress.from("myaccountaddressstring"); | ||
// Derieve an account from private key and address | ||
const account = await Account.fromPrivateKeyAndAddress({ privateKey, address }); | ||
``` | ||
#### Derive from path | ||
@@ -115,7 +142,7 @@ | ||
const transaction = await aptos.transaction.build.simple({ | ||
sender: alice, | ||
sender: alice.accountAddress, | ||
data: { | ||
function: "0x1::coin::transfer", | ||
type_arguments: ["0x1::aptos_coin::AptosCoin"], | ||
arguments: [bobAddress, 100], | ||
typeArguments: ["0x1::aptos_coin::AptosCoin"], | ||
functionArguments: [bobAddress, 100], | ||
}, | ||
@@ -157,5 +184,6 @@ }); | ||
> Note: make sure aptos local node is up and running. Take a look at the [local development network guide](https://aptos.dev/guides/local-development-network/) for more details. | ||
> Note: for a better experience, make sure there is no aptos local node process up and running (can check if there is a process running on port 8080). | ||
```bash | ||
pnpm i | ||
pnpm test | ||
@@ -162,0 +190,0 @@ ``` |
@@ -6,8 +6,10 @@ // Copyright © Aptos Foundation | ||
// Upper bound values for uint8, uint16, uint64 and uint128 | ||
export const MAX_U8_NUMBER: Uint8 = 2 ** 8 - 1; | ||
export const MAX_U16_NUMBER: Uint16 = 2 ** 16 - 1; | ||
export const MAX_U32_NUMBER: Uint32 = 2 ** 32 - 1; | ||
export const MAX_U64_BIG_INT: Uint64 = BigInt(2) ** BigInt(64) - BigInt(1); | ||
export const MAX_U128_BIG_INT: Uint128 = BigInt(2) ** BigInt(128) - BigInt(1); | ||
export const MAX_U256_BIG_INT: Uint256 = BigInt(2) ** BigInt(256) - BigInt(1); | ||
// Upper bound values for uint8, uint16, uint64 etc. These are all derived as | ||
// 2^N - 1, where N is the number of bits in the type. | ||
export const MAX_U8_NUMBER: Uint8 = 255; | ||
export const MAX_U16_NUMBER: Uint16 = 65535; | ||
export const MAX_U32_NUMBER: Uint32 = 4294967295; | ||
export const MAX_U64_BIG_INT: Uint64 = 18446744073709551615n; | ||
export const MAX_U128_BIG_INT: Uint128 = 340282366920938463463374607431768211455n; | ||
export const MAX_U256_BIG_INT: Uint256 = | ||
115792089237316195423570985008687907853269984665640564039457584007913129639935n; |
@@ -56,4 +56,3 @@ // Copyright © Aptos Foundation | ||
STRING: "0x1::string::String", | ||
// TODO support array/vector property types and values | ||
// ARRAY: "vector<u8>", | ||
ARRAY: "vector<u8>", | ||
}; | ||
@@ -64,3 +63,5 @@ | ||
// Accepted property value types for user input | ||
export type PropertyValue = boolean | number | bigint | string | AccountAddress | Array<PropertyValue>; | ||
// To pass in an Array, use Uint8Array type | ||
// for example `new MoveVector([new MoveString("hello"), new MoveString("world")]).bcsToBytes()` | ||
export type PropertyValue = boolean | number | bigint | string | AccountAddress | Uint8Array; | ||
@@ -701,3 +702,2 @@ // The default digital asset type to use if non provided | ||
const results = new Array<Uint8Array>(); | ||
propertyTypes.forEach((typ, index) => { | ||
@@ -704,0 +704,0 @@ results.push(getSinglePropertyValueRaw(propertyValues[index], typ)); |
@@ -70,3 +70,3 @@ // Copyright © Aptos Foundation | ||
case TransactionPayloadVariants.Multisig: | ||
return TransactionPayloadMultisig.load(deserializer); | ||
return TransactionPayloadMultiSig.load(deserializer); | ||
default: | ||
@@ -125,3 +125,3 @@ throw new Error(`Unknown variant index for TransactionPayload: ${index}`); | ||
*/ | ||
export class TransactionPayloadMultisig extends TransactionPayload { | ||
export class TransactionPayloadMultiSig extends TransactionPayload { | ||
public readonly multiSig: MultiSig; | ||
@@ -139,5 +139,5 @@ | ||
static load(deserializer: Deserializer): TransactionPayloadMultisig { | ||
const multiSig = MultiSig.deserialize(deserializer); | ||
return new TransactionPayloadMultisig(multiSig); | ||
static load(deserializer: Deserializer): TransactionPayloadMultiSig { | ||
const value = MultiSig.deserialize(deserializer); | ||
return new TransactionPayloadMultiSig(value); | ||
} | ||
@@ -340,3 +340,3 @@ } | ||
public readonly transaction_payload?: MultisigTransactionPayload; | ||
public readonly transaction_payload?: MultiSigTransactionPayload; | ||
@@ -351,3 +351,3 @@ /** | ||
*/ | ||
constructor(multisig_address: AccountAddress, transaction_payload?: MultisigTransactionPayload) { | ||
constructor(multisig_address: AccountAddress, transaction_payload?: MultiSigTransactionPayload) { | ||
this.multisig_address = multisig_address; | ||
@@ -374,3 +374,3 @@ this.transaction_payload = transaction_payload; | ||
if (payloadPresent) { | ||
transaction_payload = MultisigTransactionPayload.deserialize(deserializer); | ||
transaction_payload = MultiSigTransactionPayload.deserialize(deserializer); | ||
} | ||
@@ -389,3 +389,3 @@ return new MultiSig(multisig_address, transaction_payload); | ||
*/ | ||
export class MultisigTransactionPayload { | ||
export class MultiSigTransactionPayload extends Serializable { | ||
public readonly transaction_payload: EntryFunction; | ||
@@ -401,2 +401,3 @@ | ||
constructor(transaction_payload: EntryFunction) { | ||
super(); | ||
this.transaction_payload = transaction_payload; | ||
@@ -415,7 +416,8 @@ } | ||
static deserialize(deserializer: Deserializer): MultisigTransactionPayload { | ||
// This is the enum value indicating which type of payload the multi-sig transaction contains. | ||
static deserialize(deserializer: Deserializer): MultiSigTransactionPayload { | ||
// TODO: Support other types of payload beside EntryFunction. | ||
// This is the enum value indicating which type of payload the multisig tx contains. | ||
deserializer.deserializeUleb128AsU32(); | ||
return new MultisigTransactionPayload(EntryFunction.deserialize(deserializer)); | ||
return new MultiSigTransactionPayload(EntryFunction.deserialize(deserializer)); | ||
} | ||
} |
@@ -45,7 +45,7 @@ // Copyright © Aptos Foundation | ||
MultiSig, | ||
MultisigTransactionPayload, | ||
MultiSigTransactionPayload, | ||
RawTransaction, | ||
Script, | ||
TransactionPayloadEntryFunction, | ||
TransactionPayloadMultisig, | ||
TransactionPayloadMultiSig, | ||
TransactionPayloadScript, | ||
@@ -93,7 +93,7 @@ } from "../instances"; | ||
args: InputMultiSigDataWithRemoteABI, | ||
): Promise<TransactionPayloadMultisig>; | ||
): Promise<TransactionPayloadMultiSig>; | ||
/** | ||
* Builds a transaction payload based on the data argument and returns | ||
* a transaction payload - TransactionPayloadScript | TransactionPayloadMultisig | TransactionPayloadEntryFunction | ||
* a transaction payload - TransactionPayloadScript | TransactionPayloadMultiSig | TransactionPayloadEntryFunction | ||
* | ||
@@ -132,3 +132,3 @@ * This uses the RemoteABI by default, and the remote ABI can be skipped by using generateTransactionPayloadWithABI | ||
functionAbi: EntryFunctionABI, | ||
): TransactionPayloadMultisig; | ||
): TransactionPayloadMultiSig; | ||
export function generateTransactionPayloadWithABI( | ||
@@ -178,4 +178,4 @@ args: InputGenerateTransactionPayloadData, | ||
const multisigAddress = AccountAddress.from(args.multisigAddress); | ||
return new TransactionPayloadMultisig( | ||
new MultiSig(multisigAddress, new MultisigTransactionPayload(entryFunctionPayload)), | ||
return new TransactionPayloadMultiSig( | ||
new MultiSig(multisigAddress, new MultiSigTransactionPayload(entryFunctionPayload)), | ||
); | ||
@@ -182,0 +182,0 @@ } |
@@ -15,3 +15,3 @@ // Copyright © Aptos Foundation | ||
TransactionPayloadEntryFunction, | ||
TransactionPayloadMultisig, | ||
TransactionPayloadMultiSig, | ||
TransactionPayloadScript, | ||
@@ -81,5 +81,5 @@ } from "./instances"; | ||
export type InputGenerateTransactionOptions = { | ||
maxGasAmount?: AnyNumber; | ||
gasUnitPrice?: AnyNumber; | ||
expireTimestamp?: AnyNumber; | ||
maxGasAmount?: number; | ||
gasUnitPrice?: number; | ||
expireTimestamp?: number; | ||
accountSequenceNumber?: AnyNumber; | ||
@@ -94,3 +94,3 @@ }; | ||
| TransactionPayloadScript | ||
| TransactionPayloadMultisig; | ||
| TransactionPayloadMultiSig; | ||
@@ -97,0 +97,0 @@ /** |
@@ -9,2 +9,2 @@ // Copyright © Aptos Foundation | ||
*/ | ||
export const VERSION = "1.2.0"; | ||
export const VERSION = "1.3.0"; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6320770
603
41700
213
28
2