@aptos-labs/ts-sdk
Advanced tools
Comparing version 0.0.8 to 1.0.0
@@ -82,3 +82,3 @@ { | ||
}, | ||
"version": "0.0.8" | ||
"version": "1.0.0" | ||
} |
@@ -8,2 +8,3 @@ # Typescript SDK for Aptos | ||
### Latest Version | ||
[![NPM Package Version][npm-image-version]][npm-url] | ||
@@ -14,11 +15,7 @@ ![Node Version](https://img.shields.io/node/v/%40aptos-labs%2Fts-sdk) | ||
### Experimental Development Version | ||
[![NPM Experimental Version](https://img.shields.io/npm/v/%40aptos-labs/ts-sdk/experimental)][experimental-url] | ||
![Experimental Node Version](https://img.shields.io/node/v/%40aptos-labs%2Fts-sdk/experimental) | ||
![Experimental bundle size](https://img.shields.io/bundlephobia/min/%40aptos-labs/ts-sdk/experimental | ||
) | ||
![Experimental bundle size](https://img.shields.io/bundlephobia/min/%40aptos-labs/ts-sdk/experimental) | ||
> **This library is experimental**. Therefore, the API is unstable and may change without warning. | ||
The Aptos TypeScript SDK provides a convenient way to interact with the Aptos blockchain using TypeScript. It offers a | ||
@@ -36,3 +33,3 @@ set of utility functions, classes, and types to simplify the integration process and enhance developer productivity. | ||
```bash | ||
pnpm install @aptos-labs/ts-sdk@experimental | ||
pnpm install @aptos-labs/ts-sdk | ||
``` | ||
@@ -45,3 +42,3 @@ | ||
```html | ||
<script src="https://unpkg.com/@aptos-labs/ts-sdk@experimental/dist/browser/index.global.js" /> | ||
<script src="https://unpkg.com/@aptos-labs/ts-sdk/dist/browser/index.global.js" /> | ||
``` | ||
@@ -64,3 +61,3 @@ | ||
// an optional config information for the SDK client instance. | ||
const config = new AptosConfig({ network: Network.LOCAL }); | ||
const config = new AptosConfig({ network: Network.LOCAL }); // default network is devnet | ||
const aptos = new Aptos(config); | ||
@@ -77,3 +74,3 @@ ``` | ||
### Keys management (default to Ed25519) | ||
### Account management (default to Ed25519) | ||
@@ -121,4 +118,5 @@ > Note: We introduce a Single Sender authentication (as introduced in [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263)). Generating an account defaults to Legacy Ed25519 authentication with the option to use the Single Sender unified authentication | ||
const bobAddress = "0xb0b"; | ||
// build transaction | ||
const transaction = await aptos.build.transaction({ | ||
sender: alice.accountAddress.toString(), | ||
sender: alice, | ||
data: { | ||
@@ -142,7 +140,8 @@ function: "0x1::coin::transfer", | ||
```ts | ||
const alice: Account; | ||
const alice: Account = Account.generate(); | ||
const bobAddress = "0xb0b"; | ||
// build transaction | ||
const transaction = await aptos.transferCoinTransaction({ | ||
sender: alice.accountAddress.toString(), | ||
recipient: bob, | ||
sender: alice, | ||
recipient: bobAddress, | ||
amount: 100, | ||
@@ -156,2 +155,3 @@ }); | ||
- For full SDK documentation, check out the [TypeScript SDK documentation](https://aptos.dev/sdks/ts-sdk-v2/) | ||
- For reference documenation, check out the [API reference documentation](https://aptos-labs.github.io/aptos-ts-sdk/) for the associated version. | ||
@@ -158,0 +158,0 @@ - For in-depth examples, check out the [examples](./examples) folder with ready-made `package.json` files to get you going quickly! |
@@ -11,2 +11,3 @@ // Copyright © Aptos Foundation | ||
GetTokenDataResponse, | ||
MoveStructId, | ||
OrderByArg, | ||
@@ -17,3 +18,3 @@ PaginationArgs, | ||
} from "../types"; | ||
import { Account, AccountAddressInput } from "../core"; | ||
import { Account, AccountAddress, AccountAddressInput } from "../core"; | ||
import { InputGenerateTransactionOptions, SingleSignerTransaction } from "../transactions/types"; | ||
@@ -30,2 +31,3 @@ import { | ||
mintTokenTransaction, | ||
transferDigitalAsset, | ||
} from "../internal/digitalAsset"; | ||
@@ -234,2 +236,25 @@ import { ProcessorType } from "../utils/const"; | ||
} | ||
/** | ||
* Transfer a digital asset (non fungible token) ownership. | ||
* | ||
* We can transfer a digital asset only when the digital asset is not frozen | ||
* (i.e. owner transfer is not disabled such as for soul bound tokens) | ||
* | ||
* @param args.sender The sender account of the current digital asset owner | ||
* @param args.digitalAssetAddress The digital asset address | ||
* @param args.recipient The recipient account address | ||
* @param args.digitalAssetType optional. The digital asset type, default to "0x4::token::Token" | ||
* | ||
* @returns A SingleSignerTransaction that can be simulated or submitted to chain | ||
*/ | ||
async transferDigitalAsset(args: { | ||
sender: Account; | ||
digitalAssetAddress: AccountAddressInput; | ||
recipient: AccountAddress; | ||
digitalAssetType?: MoveStructId; | ||
options?: InputGenerateTransactionOptions; | ||
}): Promise<SingleSignerTransaction> { | ||
return transferDigitalAsset({ aptosConfig: this.config, ...args }); | ||
} | ||
} | ||
@@ -236,0 +261,0 @@ |
@@ -22,2 +22,3 @@ // Copyright © Aptos Foundation | ||
GetTokenDataResponse, | ||
MoveStructId, | ||
OrderByArg, | ||
@@ -142,2 +143,3 @@ PaginationArgs, | ||
owner_address: { _eq: AccountAddress.from(ownerAddress).toStringLong() }, | ||
amount: { _gt: 0 }, | ||
}; | ||
@@ -290,1 +292,23 @@ | ||
} | ||
export async function transferDigitalAsset(args: { | ||
aptosConfig: AptosConfig; | ||
sender: Account; | ||
digitalAssetAddress: AccountAddressInput; | ||
recipient: AccountAddress; | ||
digitalAssetType?: MoveStructId; | ||
options?: InputGenerateTransactionOptions; | ||
}): Promise<SingleSignerTransaction> { | ||
const { aptosConfig, sender, digitalAssetAddress, recipient, digitalAssetType, options } = args; | ||
const transaction = await generateTransaction({ | ||
aptosConfig, | ||
sender: sender.accountAddress, | ||
data: { | ||
function: "0x1::object::transfer", | ||
typeArguments: [digitalAssetType ?? "0x4::token::Token"], | ||
functionArguments: [digitalAssetAddress, recipient], | ||
}, | ||
options, | ||
}); | ||
return transaction; | ||
} |
@@ -37,3 +37,3 @@ // Copyright © Aptos Foundation | ||
import { Account, AccountAddress } from "../core"; | ||
import { InputGenerateTransactionOptions } from "../transactions"; | ||
import { InputGenerateTransactionOptions, SingleSignerTransaction } from "../transactions"; | ||
import { generateTransaction } from "./transactionSubmission"; | ||
@@ -120,3 +120,3 @@ | ||
options?: InputGenerateTransactionOptions; | ||
}) { | ||
}): Promise<SingleSignerTransaction> { | ||
const { aptosConfig, sender, fungibleAssetMetadataAddress, recipient, amount, options } = args; | ||
@@ -123,0 +123,0 @@ const transaction = await generateTransaction({ |
@@ -152,3 +152,3 @@ // Copyright © Aptos Foundation | ||
} | ||
throwTypeMismatch("string", position); | ||
throwTypeMismatch("string | AccountAddress", position); | ||
} | ||
@@ -199,3 +199,3 @@ if (param.isU8()) { | ||
checkOrConvertArgument(arg, genericTypeParams[genericIndex], position, genericTypeParams); | ||
return checkOrConvertArgument(arg, genericTypeParams[genericIndex], position, genericTypeParams); | ||
} | ||
@@ -242,3 +242,3 @@ | ||
} | ||
throwTypeMismatch("string", position); | ||
throwTypeMismatch("string | AccountAddress", position); | ||
} | ||
@@ -319,3 +319,8 @@ | ||
if (arg instanceof MoveVector) { | ||
// TODO: More introspection to verify the type | ||
// If there's anything in it, check that the inner types match | ||
// Note that since it's typed, the first item should be the same as the rest | ||
if (arg.values.length > 0) { | ||
checkType(param.value, arg.values[0], position); | ||
} | ||
return; | ||
@@ -342,3 +347,6 @@ } | ||
if (arg instanceof MoveOption) { | ||
// TODO: more introspection for the type | ||
// If there's a value, we can check the inner type (otherwise it doesn't really matter) | ||
if (arg.value !== undefined) { | ||
checkType(param.value.typeArgs[0], arg.value, position); | ||
} | ||
return; | ||
@@ -345,0 +353,0 @@ } |
@@ -257,2 +257,3 @@ // Copyright © Aptos Foundation | ||
super(); | ||
if (value < 0) throw new Error("Generic type parameter index cannot be negative"); | ||
} | ||
@@ -259,0 +260,0 @@ |
@@ -9,2 +9,2 @@ // Copyright © Aptos Foundation | ||
*/ | ||
export const VERSION = "0.0.8"; | ||
export const VERSION = "1.0.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
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5874074
40097
2