@kynesyslabs/demosdk 2.2.70 → 2.3.0
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/build/demoswork/workstep.d.ts +1 -2
- package/build/demoswork/workstep.js +1 -3
- package/build/demoswork/workstep.js.map +1 -1
- package/build/multichain/core/aptos.d.ts +157 -0
- package/build/multichain/core/aptos.js +345 -0
- package/build/multichain/core/aptos.js.map +1 -0
- package/build/multichain/core/index.d.ts +1 -0
- package/build/multichain/core/index.js +3 -1
- package/build/multichain/core/index.js.map +1 -1
- package/build/multichain/localsdk/aptos.d.ts +70 -0
- package/build/multichain/localsdk/aptos.js +202 -0
- package/build/multichain/localsdk/aptos.js.map +1 -0
- package/build/multichain/localsdk/index.d.ts +1 -0
- package/build/multichain/localsdk/index.js +3 -1
- package/build/multichain/localsdk/index.js.map +1 -1
- package/build/multichain/websdk/aptos.d.ts +86 -0
- package/build/multichain/websdk/aptos.js +282 -0
- package/build/multichain/websdk/aptos.js.map +1 -0
- package/build/types/blockchain/Transaction.d.ts +3 -2
- package/build/types/blockchain/Transaction.js.map +1 -1
- package/build/types/blockchain/TransactionSubtypes/L2PSHashTransaction.d.ts +68 -0
- package/build/types/blockchain/TransactionSubtypes/L2PSHashTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/L2PSHashTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/index.d.ts +3 -1
- package/build/types/blockchain/TransactionSubtypes/index.js +1 -0
- package/build/types/blockchain/TransactionSubtypes/index.js.map +1 -1
- package/build/types/bridge/constants.js +1 -1
- package/build/types/bridge/constants.js.map +1 -1
- package/build/types/index.d.ts +2 -3
- package/build/types/index.js.map +1 -1
- package/build/types/web2/index.d.ts +0 -16
- package/build/types/web2/index.js.map +1 -1
- package/build/websdk/DemosTransactions.d.ts +26 -0
- package/build/websdk/DemosTransactions.js +51 -0
- package/build/websdk/DemosTransactions.js.map +1 -1
- package/build/websdk/Web2Calls.d.ts +2 -2
- package/build/websdk/Web2Calls.js.map +1 -1
- package/build/websdk/demosclass.d.ts +3 -0
- package/build/websdk/utils/skeletons.js +0 -4
- package/build/websdk/utils/skeletons.js.map +1 -1
- package/package.json +3 -1
|
@@ -28,11 +28,10 @@ export declare class NativeWorkStep extends WorkStep {
|
|
|
28
28
|
constructor(payload: INativePayload);
|
|
29
29
|
}
|
|
30
30
|
export declare function prepareXMStep(xm_payload: XMScript): XmWorkStep;
|
|
31
|
-
export declare function prepareWeb2Step({ method, url, parameters, headers,
|
|
31
|
+
export declare function prepareWeb2Step({ method, url, parameters, headers, }: {
|
|
32
32
|
method?: EnumWeb2Methods;
|
|
33
33
|
url?: string;
|
|
34
34
|
parameters?: any[];
|
|
35
35
|
headers?: any;
|
|
36
|
-
minAttestations?: number;
|
|
37
36
|
}): Web2WorkStep;
|
|
38
37
|
export declare function prepareNativeStep(native_payload: INativePayload): NativeWorkStep;
|
|
@@ -66,7 +66,7 @@ exports.NativeWorkStep = NativeWorkStep;
|
|
|
66
66
|
function prepareXMStep(xm_payload) {
|
|
67
67
|
return new XmWorkStep(xm_payload);
|
|
68
68
|
}
|
|
69
|
-
function prepareWeb2Step({ method = types_1.EnumWeb2Methods.GET, url = "https://icanhazip.com", parameters = [], headers = null,
|
|
69
|
+
function prepareWeb2Step({ method = types_1.EnumWeb2Methods.GET, url = "https://icanhazip.com", parameters = [], headers = null, }) {
|
|
70
70
|
// Generating an empty request and filling it
|
|
71
71
|
const web2_payload = structuredClone(websdk_1.skeletons.web2_request);
|
|
72
72
|
web2_payload.raw.action = types_2.EnumWeb2Actions.CREATE;
|
|
@@ -74,9 +74,7 @@ function prepareWeb2Step({ method = types_1.EnumWeb2Methods.GET, url = "https://
|
|
|
74
74
|
web2_payload.raw.url = url;
|
|
75
75
|
web2_payload.raw.parameters = parameters;
|
|
76
76
|
web2_payload.raw.headers = headers;
|
|
77
|
-
web2_payload.raw.minAttestations = minAttestations;
|
|
78
77
|
// Ensuring content is a known property
|
|
79
|
-
web2_payload.attestations = new Map();
|
|
80
78
|
web2_payload.hash = "";
|
|
81
79
|
web2_payload.signature = {
|
|
82
80
|
type: "ed25519",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workstep.js","sourceRoot":"","sources":["../../../src/demoswork/workstep.ts"],"names":[],"mappings":";;;AA2EA,sCAEC;AAED,
|
|
1
|
+
{"version":3,"file":"workstep.js","sourceRoot":"","sources":["../../../src/demoswork/workstep.ts"],"names":[],"mappings":";;;AA2EA,sCAEC;AAED,0CAqBC;AAED,8CAEC;AAxGD,mCAAmC;AAEnC,qCAAoC;AACpC,mCAAiE;AAEjE,2DAAuD;AAEvD,mCAAyC;AAEzC,MAAa,QAAQ;IASjB,YAAY,OAAsB;QAJlC,cAAS,GAAW,IAAI,CAAC,GAAG,EAAE,CAAA;QAC9B,aAAQ,GAAY,KAAK,CAAA;QACzB,eAAU,GAAa,EAAE,CAAA;QAGrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,EAAE,GAAG,OAAO,GAAG,IAAA,iBAAS,GAAE,CAAA;IACnC,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,KAAK,CACZ;YACI,IAAI,EAAE,qBAAS,CAAC,IAAI;YACpB,GAAG,EAAE;gBACD,IAAI,EAAE,IAAI;gBACV,GAAG,EAAE,QAAQ;aAChB;SACG,EACR;YACI,GAAG,EAAE,CAAC,MAAM,EAAE,IAAqB,EAAE,EAAE;gBACnC,OAAO;oBACH,IAAI,EAAE,qBAAS,CAAC,IAAI;oBACpB,GAAG,EAAE;wBACD,IAAI,EAAE,IAAI;wBACV,GAAG,EAAE,UAAU,MAAM,CAAC,IAAI,CAAC,EAAE;qBAChC;iBACJ,CAAA;YACL,CAAC;SACJ,CACJ,CAAA;IACL,CAAC;IACD,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,MAAkC,CAAA;IAClD,CAAC;CACJ;AAvCD,4BAuCC;AAED,MAAa,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AG,EAAE,CAAA;IACxB,OAAO,IAAI,YAAY,CAAC,YAAY,CAAC,CAAA;AACzC,CAAC;AAED,SAAgB,iBAAiB,CAAC,cAA8B;IAC5D,OAAO,IAAI,cAAc,CAAC,cAAc,CAAC,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { Aptos, Network, Account, SimpleTransaction, UserTransactionResponse } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import { DefaultChain } from "./types/defaultChain";
|
|
3
|
+
import { IPayParams } from "./types/interfaces";
|
|
4
|
+
/**
|
|
5
|
+
* Extension methods for the Aptos Default Chain SDK
|
|
6
|
+
*/
|
|
7
|
+
export interface AptosDefaultChain extends DefaultChain {
|
|
8
|
+
aptos: Aptos;
|
|
9
|
+
account: Account | null;
|
|
10
|
+
network: Network;
|
|
11
|
+
/**
|
|
12
|
+
* Get APT balance for an account
|
|
13
|
+
*/
|
|
14
|
+
getAPTBalance: (address: string) => Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Get coin balance for a specific coin type
|
|
17
|
+
*/
|
|
18
|
+
getCoinBalance: (coinType: string, address: string) => Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Read from a smart contract (view function)
|
|
21
|
+
*/
|
|
22
|
+
readFromContract: (moduleAddress: string, moduleName: string, functionName: string, args: any[]) => Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Write to a smart contract (entry function)
|
|
25
|
+
*/
|
|
26
|
+
writeToContract: (moduleAddress: string, moduleName: string, functionName: string, args: any[], typeArguments?: string[]) => Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Wait for transaction confirmation
|
|
29
|
+
*/
|
|
30
|
+
waitForTransaction: (transactionHash: string) => Promise<UserTransactionResponse>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Aptos SDK implementation following official @aptos-labs/ts-sdk patterns
|
|
34
|
+
*/
|
|
35
|
+
export declare class APTOS extends DefaultChain implements AptosDefaultChain {
|
|
36
|
+
provider: Aptos;
|
|
37
|
+
aptos: Aptos;
|
|
38
|
+
account: Account | null;
|
|
39
|
+
network: Network;
|
|
40
|
+
constructor(rpc_url?: string, network?: Network);
|
|
41
|
+
/**
|
|
42
|
+
* Sets the RPC URL and reinitializes the Aptos client
|
|
43
|
+
*/
|
|
44
|
+
setRpc(rpc_url: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the network and reinitializes the Aptos client
|
|
47
|
+
*/
|
|
48
|
+
setNetwork(network: Network): void;
|
|
49
|
+
/**
|
|
50
|
+
* Connects to the Aptos network
|
|
51
|
+
* @returns A boolean indicating whether the connection was successful
|
|
52
|
+
*/
|
|
53
|
+
connect(): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Connects to a wallet using a private key
|
|
56
|
+
* @param privateKey The private key of the wallet (hex string)
|
|
57
|
+
* @returns The Account object
|
|
58
|
+
*/
|
|
59
|
+
connectWallet(privateKey: string): Promise<Account>;
|
|
60
|
+
/**
|
|
61
|
+
* Gets the APT balance of a wallet
|
|
62
|
+
* @param address The wallet address
|
|
63
|
+
* @returns The balance as a string (in Octas, 1 APT = 100,000,000 Octas)
|
|
64
|
+
*/
|
|
65
|
+
getBalance(address: string): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the APT balance using official SDK method
|
|
68
|
+
* @param address The wallet address
|
|
69
|
+
* @returns The balance as a string (in Octas)
|
|
70
|
+
*/
|
|
71
|
+
getAPTBalance(address: string): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Gets the balance of a specific coin type
|
|
74
|
+
* @param coinType The coin type (e.g., "0x1::aptos_coin::AptosCoin")
|
|
75
|
+
* @param address The wallet address
|
|
76
|
+
* @returns The balance as a string
|
|
77
|
+
*/
|
|
78
|
+
getCoinBalance(coinType: string, address: string): Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a signed transaction to transfer APT
|
|
81
|
+
* @param receiver The receiver's address
|
|
82
|
+
* @param amount The amount to transfer (in Octas)
|
|
83
|
+
* @returns The signed transaction
|
|
84
|
+
*/
|
|
85
|
+
preparePay(receiver: string, amount: string): Promise<Uint8Array>;
|
|
86
|
+
/**
|
|
87
|
+
* Creates multiple signed transactions to transfer APT
|
|
88
|
+
* @param payments Array of payment parameters
|
|
89
|
+
* @returns Array of signed transactions
|
|
90
|
+
*/
|
|
91
|
+
preparePays(payments: IPayParams[]): Promise<Uint8Array[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Creates an empty transaction template
|
|
94
|
+
*/
|
|
95
|
+
getEmptyTransaction(): Promise<SimpleTransaction>;
|
|
96
|
+
/**
|
|
97
|
+
* Returns the address of the connected wallet
|
|
98
|
+
*/
|
|
99
|
+
getAddress(): string;
|
|
100
|
+
/**
|
|
101
|
+
* Signs a message using the connected wallet
|
|
102
|
+
* @param message The message to sign
|
|
103
|
+
* @returns The signed message
|
|
104
|
+
*/
|
|
105
|
+
signMessage(message: string): Promise<Uint8Array>;
|
|
106
|
+
/**
|
|
107
|
+
* Verifies a message signature
|
|
108
|
+
* @param message The original message
|
|
109
|
+
* @param signature The signature to verify
|
|
110
|
+
* @param publicKey The public key to verify against
|
|
111
|
+
* @returns Boolean indicating if the signature is valid
|
|
112
|
+
*/
|
|
113
|
+
verifyMessage(message: string, signature: string | Uint8Array, publicKey: string | Uint8Array): Promise<boolean>;
|
|
114
|
+
/**
|
|
115
|
+
* Signs a transaction using the connected wallet
|
|
116
|
+
* @param transaction The transaction to sign
|
|
117
|
+
* @returns The signed transaction
|
|
118
|
+
*/
|
|
119
|
+
signTransaction(transaction: SimpleTransaction): Promise<Uint8Array>;
|
|
120
|
+
/**
|
|
121
|
+
* Signs multiple transactions
|
|
122
|
+
* @param transactions Array of transactions to sign
|
|
123
|
+
* @returns Array of signed transactions
|
|
124
|
+
*/
|
|
125
|
+
signTransactions(transactions: SimpleTransaction[]): Promise<Uint8Array[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Read from a smart contract (view function)
|
|
128
|
+
* @param moduleAddress The module address
|
|
129
|
+
* @param moduleName The module name
|
|
130
|
+
* @param functionName The function name
|
|
131
|
+
* @param args Function arguments
|
|
132
|
+
* @returns The function result
|
|
133
|
+
*/
|
|
134
|
+
readFromContract(moduleAddress: string, moduleName: string, functionName: string, args: any[]): Promise<any>;
|
|
135
|
+
/**
|
|
136
|
+
* Write to a smart contract (entry function)
|
|
137
|
+
* @param moduleAddress The module address
|
|
138
|
+
* @param moduleName The module name
|
|
139
|
+
* @param functionName The function name
|
|
140
|
+
* @param args Function arguments
|
|
141
|
+
* @param typeArguments Type arguments (optional)
|
|
142
|
+
* @returns The transaction hash
|
|
143
|
+
*/
|
|
144
|
+
writeToContract(moduleAddress: string, moduleName: string, functionName: string, args: any[], typeArguments?: string[]): Promise<string>;
|
|
145
|
+
/**
|
|
146
|
+
* Wait for transaction confirmation
|
|
147
|
+
* @param transactionHash The transaction hash
|
|
148
|
+
* @returns The transaction response
|
|
149
|
+
*/
|
|
150
|
+
waitForTransaction(transactionHash: string): Promise<UserTransactionResponse>;
|
|
151
|
+
/**
|
|
152
|
+
* Check if an address is valid
|
|
153
|
+
* @param address The address to validate
|
|
154
|
+
* @returns Boolean indicating if the address is valid
|
|
155
|
+
*/
|
|
156
|
+
isAddress(address: string): boolean;
|
|
157
|
+
}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APTOS = void 0;
|
|
4
|
+
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
|
5
|
+
const defaultChain_1 = require("./types/defaultChain");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
/**
|
|
8
|
+
* Aptos SDK implementation following official @aptos-labs/ts-sdk patterns
|
|
9
|
+
*/
|
|
10
|
+
class APTOS extends defaultChain_1.DefaultChain {
|
|
11
|
+
constructor(rpc_url = "", network = ts_sdk_1.Network.DEVNET) {
|
|
12
|
+
super(rpc_url);
|
|
13
|
+
this.account = null;
|
|
14
|
+
this.name = "aptos";
|
|
15
|
+
this.network = network;
|
|
16
|
+
// Initialize Aptos client with network configuration
|
|
17
|
+
const config = new ts_sdk_1.AptosConfig({
|
|
18
|
+
network: this.network,
|
|
19
|
+
// If custom RPC URL provided, use it
|
|
20
|
+
...(rpc_url && { fullnode: rpc_url })
|
|
21
|
+
});
|
|
22
|
+
this.aptos = new ts_sdk_1.Aptos(config);
|
|
23
|
+
this.provider = this.aptos;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sets the RPC URL and reinitializes the Aptos client
|
|
27
|
+
*/
|
|
28
|
+
setRpc(rpc_url) {
|
|
29
|
+
this.rpc_url = rpc_url;
|
|
30
|
+
const config = new ts_sdk_1.AptosConfig({
|
|
31
|
+
network: this.network,
|
|
32
|
+
fullnode: rpc_url
|
|
33
|
+
});
|
|
34
|
+
this.aptos = new ts_sdk_1.Aptos(config);
|
|
35
|
+
this.provider = this.aptos;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sets the network and reinitializes the Aptos client
|
|
39
|
+
*/
|
|
40
|
+
setNetwork(network) {
|
|
41
|
+
this.network = network;
|
|
42
|
+
const config = new ts_sdk_1.AptosConfig({
|
|
43
|
+
network: this.network,
|
|
44
|
+
...(this.rpc_url && { fullnode: this.rpc_url })
|
|
45
|
+
});
|
|
46
|
+
this.aptos = new ts_sdk_1.Aptos(config);
|
|
47
|
+
this.provider = this.aptos;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Connects to the Aptos network
|
|
51
|
+
* @returns A boolean indicating whether the connection was successful
|
|
52
|
+
*/
|
|
53
|
+
async connect() {
|
|
54
|
+
try {
|
|
55
|
+
// Test connection by getting ledger info
|
|
56
|
+
await this.aptos.getLedgerInfo();
|
|
57
|
+
this.connected = true;
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error("Failed to connect to Aptos network:", error);
|
|
62
|
+
this.connected = false;
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Connects to a wallet using a private key
|
|
68
|
+
* @param privateKey The private key of the wallet (hex string)
|
|
69
|
+
* @returns The Account object
|
|
70
|
+
*/
|
|
71
|
+
async connectWallet(privateKey) {
|
|
72
|
+
(0, utils_1.required)(privateKey, "Private key is required");
|
|
73
|
+
try {
|
|
74
|
+
// Create Ed25519PrivateKey from hex string
|
|
75
|
+
const privateKeyBytes = new ts_sdk_1.Ed25519PrivateKey(privateKey);
|
|
76
|
+
// Create account from private key using official SDK method
|
|
77
|
+
this.account = ts_sdk_1.Account.fromPrivateKey({ privateKey: privateKeyBytes });
|
|
78
|
+
this.wallet = this.account;
|
|
79
|
+
return this.account;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw new Error(`Failed to connect wallet: ${error}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets the APT balance of a wallet
|
|
87
|
+
* @param address The wallet address
|
|
88
|
+
* @returns The balance as a string (in Octas, 1 APT = 100,000,000 Octas)
|
|
89
|
+
*/
|
|
90
|
+
async getBalance(address) {
|
|
91
|
+
return this.getAPTBalance(address);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Gets the APT balance using official SDK method
|
|
95
|
+
* @param address The wallet address
|
|
96
|
+
* @returns The balance as a string (in Octas)
|
|
97
|
+
*/
|
|
98
|
+
async getAPTBalance(address) {
|
|
99
|
+
try {
|
|
100
|
+
const balance = await this.aptos.getAccountAPTAmount({
|
|
101
|
+
accountAddress: address
|
|
102
|
+
});
|
|
103
|
+
return balance.toString();
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw new Error(`Failed to get APT balance: ${error}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Gets the balance of a specific coin type
|
|
111
|
+
* @param coinType The coin type (e.g., "0x1::aptos_coin::AptosCoin")
|
|
112
|
+
* @param address The wallet address
|
|
113
|
+
* @returns The balance as a string
|
|
114
|
+
*/
|
|
115
|
+
async getCoinBalance(coinType, address) {
|
|
116
|
+
try {
|
|
117
|
+
const resource = await this.aptos.getAccountResource({
|
|
118
|
+
accountAddress: address,
|
|
119
|
+
resourceType: `0x1::coin::CoinStore<${coinType}>`
|
|
120
|
+
});
|
|
121
|
+
return resource.coin.value;
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
throw new Error(`Failed to get coin balance: ${error}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Creates a signed transaction to transfer APT
|
|
129
|
+
* @param receiver The receiver's address
|
|
130
|
+
* @param amount The amount to transfer (in Octas)
|
|
131
|
+
* @returns The signed transaction
|
|
132
|
+
*/
|
|
133
|
+
async preparePay(receiver, amount) {
|
|
134
|
+
(0, utils_1.required)(this.account, "Wallet not connected");
|
|
135
|
+
try {
|
|
136
|
+
// Build transaction using official SDK pattern
|
|
137
|
+
const transaction = await this.aptos.transaction.build.simple({
|
|
138
|
+
sender: this.account.accountAddress,
|
|
139
|
+
data: {
|
|
140
|
+
function: "0x1::coin::transfer",
|
|
141
|
+
typeArguments: ["0x1::aptos_coin::AptosCoin"],
|
|
142
|
+
functionArguments: [receiver, amount]
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
// Sign and submit transaction
|
|
146
|
+
const response = await this.aptos.signAndSubmitTransaction({
|
|
147
|
+
signer: this.account,
|
|
148
|
+
transaction
|
|
149
|
+
});
|
|
150
|
+
return new TextEncoder().encode(response.hash);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
throw new Error(`Failed to prepare payment: ${error}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Creates multiple signed transactions to transfer APT
|
|
158
|
+
* @param payments Array of payment parameters
|
|
159
|
+
* @returns Array of signed transactions
|
|
160
|
+
*/
|
|
161
|
+
async preparePays(payments) {
|
|
162
|
+
(0, utils_1.required)(this.account, "Wallet not connected");
|
|
163
|
+
const signedTransactions = [];
|
|
164
|
+
for (const payment of payments) {
|
|
165
|
+
const signedTx = await this.preparePay(payment.address, payment.amount.toString());
|
|
166
|
+
signedTransactions.push(signedTx);
|
|
167
|
+
}
|
|
168
|
+
return signedTransactions;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Creates an empty transaction template
|
|
172
|
+
*/
|
|
173
|
+
async getEmptyTransaction() {
|
|
174
|
+
(0, utils_1.required)(this.account, "Wallet not connected");
|
|
175
|
+
return await this.aptos.transaction.build.simple({
|
|
176
|
+
sender: this.account.accountAddress,
|
|
177
|
+
data: {
|
|
178
|
+
function: "0x1::coin::transfer",
|
|
179
|
+
typeArguments: ["0x1::aptos_coin::AptosCoin"],
|
|
180
|
+
functionArguments: ["0x1", "0"] // Placeholder values
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Returns the address of the connected wallet
|
|
186
|
+
*/
|
|
187
|
+
getAddress() {
|
|
188
|
+
(0, utils_1.required)(this.account, "Wallet not connected");
|
|
189
|
+
return this.account.accountAddress.toString();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Signs a message using the connected wallet
|
|
193
|
+
* @param message The message to sign
|
|
194
|
+
* @returns The signed message
|
|
195
|
+
*/
|
|
196
|
+
async signMessage(message) {
|
|
197
|
+
(0, utils_1.required)(this.account, "Wallet not connected");
|
|
198
|
+
try {
|
|
199
|
+
const signature = this.account.sign(new TextEncoder().encode(message));
|
|
200
|
+
return signature.toUint8Array();
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
throw new Error(`Failed to sign message: ${error}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Verifies a message signature
|
|
208
|
+
* @param message The original message
|
|
209
|
+
* @param signature The signature to verify
|
|
210
|
+
* @param publicKey The public key to verify against
|
|
211
|
+
* @returns Boolean indicating if the signature is valid
|
|
212
|
+
*/
|
|
213
|
+
async verifyMessage(message, signature, publicKey) {
|
|
214
|
+
try {
|
|
215
|
+
// Convert inputs to proper format
|
|
216
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
217
|
+
const sigBytes = typeof signature === "string"
|
|
218
|
+
? new TextEncoder().encode(signature)
|
|
219
|
+
: signature;
|
|
220
|
+
const pubKeyBytes = typeof publicKey === "string"
|
|
221
|
+
? new TextEncoder().encode(publicKey)
|
|
222
|
+
: publicKey;
|
|
223
|
+
// For now, return true as verification implementation depends on signature format
|
|
224
|
+
// TODO: Implement proper signature verification using Aptos SDK methods
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
console.error("Failed to verify message:", error);
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Signs a transaction using the connected wallet
|
|
234
|
+
* @param transaction The transaction to sign
|
|
235
|
+
* @returns The signed transaction
|
|
236
|
+
*/
|
|
237
|
+
async signTransaction(transaction) {
|
|
238
|
+
(0, utils_1.required)(this.account, "Wallet not connected");
|
|
239
|
+
try {
|
|
240
|
+
const response = await this.aptos.signAndSubmitTransaction({
|
|
241
|
+
signer: this.account,
|
|
242
|
+
transaction
|
|
243
|
+
});
|
|
244
|
+
return new TextEncoder().encode(response.hash);
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
throw new Error(`Failed to sign transaction: ${error}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Signs multiple transactions
|
|
252
|
+
* @param transactions Array of transactions to sign
|
|
253
|
+
* @returns Array of signed transactions
|
|
254
|
+
*/
|
|
255
|
+
async signTransactions(transactions) {
|
|
256
|
+
const signedTransactions = [];
|
|
257
|
+
for (const transaction of transactions) {
|
|
258
|
+
const signedTx = await this.signTransaction(transaction);
|
|
259
|
+
signedTransactions.push(signedTx);
|
|
260
|
+
}
|
|
261
|
+
return signedTransactions;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Read from a smart contract (view function)
|
|
265
|
+
* @param moduleAddress The module address
|
|
266
|
+
* @param moduleName The module name
|
|
267
|
+
* @param functionName The function name
|
|
268
|
+
* @param args Function arguments
|
|
269
|
+
* @returns The function result
|
|
270
|
+
*/
|
|
271
|
+
async readFromContract(moduleAddress, moduleName, functionName, args) {
|
|
272
|
+
try {
|
|
273
|
+
return await this.aptos.view({
|
|
274
|
+
payload: {
|
|
275
|
+
function: `${moduleAddress}::${moduleName}::${functionName}`,
|
|
276
|
+
functionArguments: args
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
throw new Error(`Failed to read from contract: ${error}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Write to a smart contract (entry function)
|
|
286
|
+
* @param moduleAddress The module address
|
|
287
|
+
* @param moduleName The module name
|
|
288
|
+
* @param functionName The function name
|
|
289
|
+
* @param args Function arguments
|
|
290
|
+
* @param typeArguments Type arguments (optional)
|
|
291
|
+
* @returns The transaction hash
|
|
292
|
+
*/
|
|
293
|
+
async writeToContract(moduleAddress, moduleName, functionName, args, typeArguments = []) {
|
|
294
|
+
(0, utils_1.required)(this.account, "Wallet not connected");
|
|
295
|
+
try {
|
|
296
|
+
const transaction = await this.aptos.transaction.build.simple({
|
|
297
|
+
sender: this.account.accountAddress,
|
|
298
|
+
data: {
|
|
299
|
+
function: `${moduleAddress}::${moduleName}::${functionName}`,
|
|
300
|
+
typeArguments,
|
|
301
|
+
functionArguments: args
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
const response = await this.aptos.signAndSubmitTransaction({
|
|
305
|
+
signer: this.account,
|
|
306
|
+
transaction
|
|
307
|
+
});
|
|
308
|
+
return response.hash;
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
throw new Error(`Failed to write to contract: ${error}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Wait for transaction confirmation
|
|
316
|
+
* @param transactionHash The transaction hash
|
|
317
|
+
* @returns The transaction response
|
|
318
|
+
*/
|
|
319
|
+
async waitForTransaction(transactionHash) {
|
|
320
|
+
try {
|
|
321
|
+
return await this.aptos.waitForTransaction({
|
|
322
|
+
transactionHash
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
throw new Error(`Failed to wait for transaction: ${error}`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Check if an address is valid
|
|
331
|
+
* @param address The address to validate
|
|
332
|
+
* @returns Boolean indicating if the address is valid
|
|
333
|
+
*/
|
|
334
|
+
isAddress(address) {
|
|
335
|
+
try {
|
|
336
|
+
ts_sdk_1.AccountAddress.from(address);
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
exports.APTOS = APTOS;
|
|
345
|
+
//# sourceMappingURL=aptos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aptos.js","sourceRoot":"","sources":["../../../../src/multichain/core/aptos.ts"],"names":[],"mappings":";;;AAAA,+CAS2B;AAE3B,uDAAmD;AAEnD,mCAAkC;AA0DlC;;GAEG;AACH,MAAa,KAAM,SAAQ,2BAAY;IAMnC,YAAY,UAAkB,EAAE,EAAE,UAAmB,gBAAO,CAAC,MAAM;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAA;QAJlB,YAAO,GAAmB,IAAI,CAAA;QAK1B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAA;QACnB,IAAI,CAAC,OAAO,GAA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,MAAM,CAAC;gBAC1D,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;gBACnC,IAAI,EAAE;oBACF,QAAQ,EAAE,GAAG,aAAa,KAAK,UAAU,KAAK,YAAY,EAAE;oBAC5D,aAAa;oBACb,iBAAiB,EAAE,IAAI;iBAC1B;aACJ,CAAC,CAAA;YAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC;gBACvD,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,WAAW;aACd,CAAC,CAAA;YAEF,OAAO,QAAQ,CAAC,IAAI,CAAA;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,EAAE,CAAC,CAAA;QAC5D,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,kBAAkB,CAAC,eAAuB;QAC5C,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC;gBACvC,eAAe;aAClB,CAA4B,CAAA;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAA;QAC/D,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,OAAe;QACrB,IAAI,CAAC;YACD,uBAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAC5B,OAAO,IAAI,CAAA;QACf,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC;CACJ;AA5XD,sBA4XC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NEAR = exports.xrplGetLastSequence = exports.XRPL = exports.BTC = exports.TON = exports.SOLANA = exports.MULTIVERSX = exports.IBC = exports.EVM = exports.required = exports.DefaultChain = void 0;
|
|
3
|
+
exports.NEAR = exports.xrplGetLastSequence = exports.XRPL = exports.APTOS = exports.BTC = exports.TON = exports.SOLANA = exports.MULTIVERSX = exports.IBC = exports.EVM = exports.required = exports.DefaultChain = void 0;
|
|
4
4
|
var defaultChain_1 = require("./types/defaultChain");
|
|
5
5
|
Object.defineProperty(exports, "DefaultChain", { enumerable: true, get: function () { return defaultChain_1.DefaultChain; } });
|
|
6
6
|
var utils_1 = require("./utils");
|
|
@@ -18,6 +18,8 @@ var ton_1 = require("./ton");
|
|
|
18
18
|
Object.defineProperty(exports, "TON", { enumerable: true, get: function () { return ton_1.TON; } });
|
|
19
19
|
var btc_1 = require("./btc");
|
|
20
20
|
Object.defineProperty(exports, "BTC", { enumerable: true, get: function () { return btc_1.BTC; } });
|
|
21
|
+
var aptos_1 = require("./aptos");
|
|
22
|
+
Object.defineProperty(exports, "APTOS", { enumerable: true, get: function () { return aptos_1.APTOS; } });
|
|
21
23
|
// The official XRPL Library is called "xrpl" which conflicts with the name of our XRPL SDK
|
|
22
24
|
var xrp_1 = require("./xrp");
|
|
23
25
|
Object.defineProperty(exports, "XRPL", { enumerable: true, get: function () { return xrp_1.XRPL; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/multichain/core/index.ts"],"names":[],"mappings":";;;AAAA,qDAM6B;AALzB,4GAAA,YAAY,OAAA;AAkBhB,iCAAkC;AAAzB,iGAAA,QAAQ,OAAA;AAEjB,sBAAsB;AACtB,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AACnB,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/multichain/core/index.ts"],"names":[],"mappings":";;;AAAA,qDAM6B;AALzB,4GAAA,YAAY,OAAA;AAkBhB,iCAAkC;AAAzB,iGAAA,QAAQ,OAAA;AAEjB,sBAAsB;AACtB,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AACnB,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AAEd,2FAA2F;AAC3F,6BAAiD;AAAxC,2FAAA,IAAI,OAAA;AAAE,0GAAA,mBAAmB,OAAA;AAClC,+BAA6B;AAApB,4FAAA,IAAI,OAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Network, Account } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import { IDefaultChainLocal, APTOS as AptosCore } from "../core";
|
|
3
|
+
import { XmTransactionResponse } from "../core/types/interfaces";
|
|
4
|
+
/**
|
|
5
|
+
* Aptos LocalSDK implementation for Node.js environments
|
|
6
|
+
* Extends the core APTOS class with local-specific functionality
|
|
7
|
+
*/
|
|
8
|
+
export declare class APTOS extends AptosCore implements IDefaultChainLocal {
|
|
9
|
+
constructor(rpc_url?: string, network?: Network);
|
|
10
|
+
/**
|
|
11
|
+
* Broadcasts a signed transaction to the Aptos network
|
|
12
|
+
* @param signed_tx The signed transaction (transaction hash as Uint8Array)
|
|
13
|
+
* @returns Transaction response with result and hash
|
|
14
|
+
*/
|
|
15
|
+
sendTransaction(signed_tx: Uint8Array): Promise<XmTransactionResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Gets network and node information
|
|
18
|
+
* @returns Network and ledger information
|
|
19
|
+
*/
|
|
20
|
+
getInfo(): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new wallet (Account) with generated keys
|
|
23
|
+
* @param password Not used in Aptos SDK, kept for interface compatibility
|
|
24
|
+
* @returns The generated Account
|
|
25
|
+
*/
|
|
26
|
+
createWallet(password: string): Promise<Account>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the private key of the connected wallet
|
|
29
|
+
* @returns The private key as hex string
|
|
30
|
+
*/
|
|
31
|
+
getPrivateKey(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the public key of the connected wallet
|
|
34
|
+
* @returns The public key as hex string
|
|
35
|
+
*/
|
|
36
|
+
getPublicKey(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Fund account using faucet (only available on devnet/testnet)
|
|
39
|
+
* @param address The address to fund
|
|
40
|
+
* @param amount The amount to fund (in Octas)
|
|
41
|
+
* @returns The transaction hash
|
|
42
|
+
*/
|
|
43
|
+
fundFromFaucet(address?: string, amount?: number): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Submit a raw transaction (already signed)
|
|
46
|
+
* @param rawTransaction The raw transaction bytes
|
|
47
|
+
* @returns The transaction response
|
|
48
|
+
*/
|
|
49
|
+
submitRawTransaction(rawTransaction: Uint8Array): Promise<XmTransactionResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Get transaction details by hash
|
|
52
|
+
* @param transactionHash The transaction hash
|
|
53
|
+
* @returns The transaction details
|
|
54
|
+
*/
|
|
55
|
+
getTransaction(transactionHash: string): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* Get account transactions
|
|
58
|
+
* @param address The account address
|
|
59
|
+
* @param start The start sequence number (optional)
|
|
60
|
+
* @param limit The maximum number of transactions to return (optional)
|
|
61
|
+
* @returns Array of transactions
|
|
62
|
+
*/
|
|
63
|
+
getAccountTransactions(address: string, start?: number, limit?: number): Promise<any[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Estimate gas for a transaction
|
|
66
|
+
* @param transaction The transaction to estimate
|
|
67
|
+
* @returns Gas estimation
|
|
68
|
+
*/
|
|
69
|
+
estimateGas(transaction: any): Promise<any>;
|
|
70
|
+
}
|