@autonomys/auto-xdm 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/info.d.ts +8 -0
- package/dist/info.d.ts.map +1 -0
- package/dist/info.js +38 -0
- package/dist/transfer.d.ts +7 -0
- package/dist/transfer.d.ts.map +1 -0
- package/dist/transfer.js +33 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Autonomys Auto XDM SDK
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://github.com/autonomys/auto-sdk/tags)
|
|
6
|
+
[](https://github.com/autonomys/auto-sdk/actions/workflows/build.yaml)
|
|
7
|
+
[](https://badge.fury.io/js/@autonomys%2Fauto-xdm)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
The **Autonomys Auto XDM SDK** (`@autonomys/auto-xdm`) provides functionalities for cross-domain transfer of native tokens.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Cross-Domain Transfer**: Transfer tokens between consensus and domain accounts.
|
|
16
|
+
- **TypeScript Support**: Fully typed for enhanced developer experience.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
Install the package via npm or yarn:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Using npm
|
|
24
|
+
npm install @autonomys/auto-xdm
|
|
25
|
+
|
|
26
|
+
# Using yarn
|
|
27
|
+
yarn add @autonomys/auto-xdm
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Getting Started
|
|
31
|
+
|
|
32
|
+
### Prerequisites
|
|
33
|
+
|
|
34
|
+
- **Node.js** (version 14 or higher)
|
|
35
|
+
- **TypeScript** (optional, but recommended for development)
|
|
36
|
+
- Familiarity with async/await and promise handling in JavaScript/TypeScript.
|
|
37
|
+
- **@autonomys/auto-utils** package installed (as it provides utility functions and API activation).
|
|
38
|
+
|
|
39
|
+
## Usage Examples
|
|
40
|
+
|
|
41
|
+
Below are examples demonstrating how to use the functions provided by `@autonomys/auto-xdm`.
|
|
42
|
+
|
|
43
|
+
### 1. Transfer from Consensus to Domain using an EVM address
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { activateWallet } from '@autonomys/auto-utils'
|
|
47
|
+
import { transferToDomainAccount20Type } from '@autonomys/auto-xdm'
|
|
48
|
+
|
|
49
|
+
const api = await activateWallet({ networkId: 'taurus', uri: '//alice' })
|
|
50
|
+
const tx = await transferToDomainAccount20Type(
|
|
51
|
+
api,
|
|
52
|
+
0, // Receiver domain (0 is Auto EVM on Taurus Testnet)
|
|
53
|
+
'0x1234567890abcdef', // Receiver domain account
|
|
54
|
+
'1000000000000000000',
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. Transfer from Consensus to Domain using an substrate address
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { activateWallet } from '@autonomys/auto-utils'
|
|
62
|
+
import { transferToDomainAccount32Type } from '@autonomys/auto-xdm'
|
|
63
|
+
|
|
64
|
+
const api = await activateWallet({ networkId: 'taurus', uri: '//alice' })
|
|
65
|
+
const tx = await transferToDomainAccount32Type(
|
|
66
|
+
api,
|
|
67
|
+
0, // Receiver domain (0 is Auto EVM on Taurus Testnet)
|
|
68
|
+
'su1234567890abcdef', // Receiver domain account
|
|
69
|
+
'1000000000000000000',
|
|
70
|
+
)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 3. Transfer from Domain to Consensus
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { activateWallet } from '@autonomys/auto-utils'
|
|
77
|
+
import { transferToConsensus } from '@autonomys/auto-xdm'
|
|
78
|
+
|
|
79
|
+
const api = await activateWallet({ networkId: 'taurus', domainId: 0, uri: '//alice' })
|
|
80
|
+
const tx = await transferToConsensus(
|
|
81
|
+
api,
|
|
82
|
+
'su1234567890abcdef', // Receiver consensus account,
|
|
83
|
+
'1000000000000000000',
|
|
84
|
+
)
|
|
85
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./info"), exports);
|
|
18
|
+
__exportStar(require("./transfer"), exports);
|
package/dist/info.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApiPromise, Codec } from '@autonomys/auto-utils';
|
|
2
|
+
export declare const chainAllowlist: (api: ApiPromise) => Promise<Codec>;
|
|
3
|
+
export declare const allCancelledTransfers: (api: ApiPromise) => Promise<Codec>;
|
|
4
|
+
export declare const chainTransfers: (api: ApiPromise) => Promise<Codec>;
|
|
5
|
+
export declare const allDomainBalances: (api: ApiPromise) => Promise<Codec>;
|
|
6
|
+
export declare const domainBalances: (api: ApiPromise, domainId: number) => Promise<Codec>;
|
|
7
|
+
export declare const allUnconfirmedTransfers: (api: ApiPromise) => Promise<Codec>;
|
|
8
|
+
//# sourceMappingURL=info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../src/info.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAE9D,eAAO,MAAM,cAAc,QAAe,UAAU,mBAEnD,CAAA;AAED,eAAO,MAAM,qBAAqB,QAAe,UAAU,mBAE1D,CAAA;AAED,eAAO,MAAM,cAAc,QAAe,UAAU,mBAEnD,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAe,UAAU,mBAEtD,CAAA;AAED,eAAO,MAAM,cAAc,QAAe,UAAU,YAAY,MAAM,mBAErE,CAAA;AAED,eAAO,MAAM,uBAAuB,QAAe,UAAU,mBAE5D,CAAA"}
|
package/dist/info.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: src/types/index.ts
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.allUnconfirmedTransfers = exports.domainBalances = exports.allDomainBalances = exports.chainTransfers = exports.allCancelledTransfers = exports.chainAllowlist = void 0;
|
|
14
|
+
const auto_consensus_1 = require("@autonomys/auto-consensus");
|
|
15
|
+
const chainAllowlist = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
return yield (0, auto_consensus_1.query)(api, 'messenger.chainAllowlist', []);
|
|
17
|
+
});
|
|
18
|
+
exports.chainAllowlist = chainAllowlist;
|
|
19
|
+
const allCancelledTransfers = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
return yield (0, auto_consensus_1.query)(api, 'transporter.cancelledTransfers', []);
|
|
21
|
+
});
|
|
22
|
+
exports.allCancelledTransfers = allCancelledTransfers;
|
|
23
|
+
const chainTransfers = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
return yield (0, auto_consensus_1.query)(api, 'transporter.chainTransfers', []);
|
|
25
|
+
});
|
|
26
|
+
exports.chainTransfers = chainTransfers;
|
|
27
|
+
const allDomainBalances = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
return yield (0, auto_consensus_1.query)(api, 'transporter.domainBalances', []);
|
|
29
|
+
});
|
|
30
|
+
exports.allDomainBalances = allDomainBalances;
|
|
31
|
+
const domainBalances = (api, domainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
return yield (0, auto_consensus_1.query)(api, 'transporter.domainBalances', [domainId]);
|
|
33
|
+
});
|
|
34
|
+
exports.domainBalances = domainBalances;
|
|
35
|
+
const allUnconfirmedTransfers = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
return yield (0, auto_consensus_1.query)(api, 'transporter.unconfirmedTransfers', []);
|
|
37
|
+
});
|
|
38
|
+
exports.allUnconfirmedTransfers = allUnconfirmedTransfers;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StringNumberOrBigInt } from '@autonomys/auto-consensus';
|
|
2
|
+
import type { ApiPromise, Codec } from '@autonomys/auto-utils';
|
|
3
|
+
export declare const transfer: (api: ApiPromise, destination: Codec, amount: StringNumberOrBigInt) => Promise<import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>>;
|
|
4
|
+
export declare const transferToConsensus: (api: ApiPromise, accountId32: string, amount: StringNumberOrBigInt) => Promise<import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>>;
|
|
5
|
+
export declare const transferToDomainAccount20Type: (api: ApiPromise, destinationDomainId: string | number, accountId20: string, amount: StringNumberOrBigInt) => Promise<import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>>;
|
|
6
|
+
export declare const transferToDomainAccount32Type: (api: ApiPromise, destinationDomainId: string | number, accountId32: string, amount: StringNumberOrBigInt) => Promise<import("@autonomys/auto-utils").SubmittableExtrinsic<"promise", import("@autonomys/auto-utils").ISubmittableResult>>;
|
|
7
|
+
//# sourceMappingURL=transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAO9D,eAAO,MAAM,QAAQ,QACd,UAAU,eACF,KAAK,UACV,oBAAoB,iIAG7B,CAAA;AAED,eAAO,MAAM,mBAAmB,QACzB,UAAU,eACF,MAAM,UACX,oBAAoB,iIAI7B,CAAA;AAED,eAAO,MAAM,6BAA6B,QACnC,UAAU,uBACM,MAAM,GAAG,MAAM,eACvB,MAAM,UACX,oBAAoB,iIAI7B,CAAA;AAED,eAAO,MAAM,6BAA6B,QACnC,UAAU,uBACM,MAAM,GAAG,MAAM,eACvB,MAAM,UACX,oBAAoB,iIAI7B,CAAA"}
|
package/dist/transfer.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: src/transfer.ts
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.transferToDomainAccount32Type = exports.transferToDomainAccount20Type = exports.transferToConsensus = exports.transfer = void 0;
|
|
14
|
+
const auto_utils_1 = require("@autonomys/auto-utils");
|
|
15
|
+
const transfer = (api, destination, amount) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
return yield api.tx.transporter.transfer(destination, amount);
|
|
17
|
+
});
|
|
18
|
+
exports.transfer = transfer;
|
|
19
|
+
const transferToConsensus = (api, accountId32, amount) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const destination = (0, auto_utils_1.createTransporterToConsensusType)(api, accountId32);
|
|
21
|
+
return yield (0, exports.transfer)(api, destination, amount);
|
|
22
|
+
});
|
|
23
|
+
exports.transferToConsensus = transferToConsensus;
|
|
24
|
+
const transferToDomainAccount20Type = (api, destinationDomainId, accountId20, amount) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
const destination = (0, auto_utils_1.createTransporterToDomainAccount20Type)(api, destinationDomainId, accountId20);
|
|
26
|
+
return yield (0, exports.transfer)(api, destination, amount);
|
|
27
|
+
});
|
|
28
|
+
exports.transferToDomainAccount20Type = transferToDomainAccount20Type;
|
|
29
|
+
const transferToDomainAccount32Type = (api, destinationDomainId, accountId32, amount) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
const destination = (0, auto_utils_1.createTransporterToDomainAccount32Type)(api, destinationDomainId, accountId32);
|
|
31
|
+
return yield (0, exports.transfer)(api, destination, amount);
|
|
32
|
+
});
|
|
33
|
+
exports.transferToDomainAccount32Type = transferToDomainAccount32Type;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Consensus = {
|
|
2
|
+
type: 'consensus';
|
|
3
|
+
};
|
|
4
|
+
export type Domain = {
|
|
5
|
+
type: 'domain';
|
|
6
|
+
domainId: number;
|
|
7
|
+
};
|
|
8
|
+
export type ChainOrDomain = Consensus | Domain;
|
|
9
|
+
export type AccountId20 = {
|
|
10
|
+
accountId20: string;
|
|
11
|
+
};
|
|
12
|
+
export type AccountId32 = {
|
|
13
|
+
accountId32: string;
|
|
14
|
+
};
|
|
15
|
+
export type Account = AccountId20 | AccountId32;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,WAAW,CAAA;CAClB,CAAA;AACD,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AACD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,CAAA;AAC9C,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AACD,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AACD,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,WAAW,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@autonomys/auto-xdm",
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/autonomys/auto-sdk"
|
|
9
|
+
},
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Autonomys",
|
|
12
|
+
"url": "https://www.autonomys.xyz"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/autonomys/auto-sdk/issues"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"clean": "rm -rf dist",
|
|
20
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
21
|
+
"test-local": "jest -i"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@autonomys/auto-consensus": "^1.2.3",
|
|
29
|
+
"@autonomys/auto-utils": "^1.2.3"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/jest": "^29.5.12",
|
|
33
|
+
"eslint": "^8.57.0",
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"prettier": "^3.2.5",
|
|
36
|
+
"ts-jest": "^29.1.4",
|
|
37
|
+
"typescript": "^5.4.5"
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "53cf74430ba08ed3b8f38ccc2fcee7b373a7934c"
|
|
40
|
+
}
|