@kynesyslabs/demosdk 2.2.71 → 2.3.1
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/multichain/core/aptos.d.ts +158 -0
- package/build/multichain/core/aptos.js +367 -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/bridge/constants.js +1 -1
- package/build/types/bridge/constants.js.map +1 -1
- package/build/types/index.d.ts +0 -1
- package/package.json +3 -1
|
@@ -0,0 +1,158 @@
|
|
|
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[], typeArguments?: string[]) => 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
|
+
* @param typeArguments Type arguments for generic functions (optional)
|
|
133
|
+
* @returns The function result
|
|
134
|
+
*/
|
|
135
|
+
readFromContract(moduleAddress: string, moduleName: string, functionName: string, args: any[], typeArguments?: string[]): Promise<any>;
|
|
136
|
+
/**
|
|
137
|
+
* Write to a smart contract (entry function)
|
|
138
|
+
* @param moduleAddress The module address
|
|
139
|
+
* @param moduleName The module name
|
|
140
|
+
* @param functionName The function name
|
|
141
|
+
* @param args Function arguments
|
|
142
|
+
* @param typeArguments Type arguments (optional)
|
|
143
|
+
* @returns The transaction hash
|
|
144
|
+
*/
|
|
145
|
+
writeToContract(moduleAddress: string, moduleName: string, functionName: string, args: any[], typeArguments?: string[]): Promise<string>;
|
|
146
|
+
/**
|
|
147
|
+
* Wait for transaction confirmation
|
|
148
|
+
* @param transactionHash The transaction hash
|
|
149
|
+
* @returns The transaction response
|
|
150
|
+
*/
|
|
151
|
+
waitForTransaction(transactionHash: string): Promise<UserTransactionResponse>;
|
|
152
|
+
/**
|
|
153
|
+
* Check if an address is valid
|
|
154
|
+
* @param address The address to validate
|
|
155
|
+
* @returns Boolean indicating if the address is valid
|
|
156
|
+
*/
|
|
157
|
+
isAddress(address: string): boolean;
|
|
158
|
+
}
|
|
@@ -0,0 +1,367 @@
|
|
|
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
|
+
* @param typeArguments Type arguments for generic functions (optional)
|
|
270
|
+
* @returns The function result
|
|
271
|
+
*/
|
|
272
|
+
async readFromContract(moduleAddress, moduleName, functionName, args, typeArguments = []) {
|
|
273
|
+
try {
|
|
274
|
+
// Validate module address format
|
|
275
|
+
if (!this.isAddress(moduleAddress)) {
|
|
276
|
+
throw new Error(`Invalid module address format: ${moduleAddress}`);
|
|
277
|
+
}
|
|
278
|
+
// Build the view function payload with proper typing
|
|
279
|
+
const fullFunctionName = `${moduleAddress}::${moduleName}::${functionName}`;
|
|
280
|
+
const payload = {
|
|
281
|
+
function: fullFunctionName,
|
|
282
|
+
functionArguments: args,
|
|
283
|
+
...(typeArguments.length > 0 && { typeArguments })
|
|
284
|
+
};
|
|
285
|
+
const result = await this.aptos.view({ payload });
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
// Enhanced error handling for Move-specific errors
|
|
290
|
+
const errorMsg = error?.message || error?.toString() || 'Unknown error';
|
|
291
|
+
if (errorMsg.includes('MODULE_NOT_FOUND')) {
|
|
292
|
+
throw new Error(`Module not found: ${moduleAddress}::${moduleName}`);
|
|
293
|
+
}
|
|
294
|
+
else if (errorMsg.includes('FUNCTION_NOT_FOUND')) {
|
|
295
|
+
throw new Error(`Function not found: ${functionName} in ${moduleAddress}::${moduleName}`);
|
|
296
|
+
}
|
|
297
|
+
else if (errorMsg.includes('Type argument count mismatch')) {
|
|
298
|
+
throw new Error(`Type argument mismatch for ${functionName}. Expected different count than ${typeArguments.length}`);
|
|
299
|
+
}
|
|
300
|
+
else if (errorMsg.includes('INVALID_ARGUMENT')) {
|
|
301
|
+
throw new Error(`Invalid arguments for ${functionName}: ${JSON.stringify(args)}`);
|
|
302
|
+
}
|
|
303
|
+
throw new Error(`Failed to read from contract ${moduleAddress}::${moduleName}::${functionName}: ${errorMsg}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Write to a smart contract (entry function)
|
|
308
|
+
* @param moduleAddress The module address
|
|
309
|
+
* @param moduleName The module name
|
|
310
|
+
* @param functionName The function name
|
|
311
|
+
* @param args Function arguments
|
|
312
|
+
* @param typeArguments Type arguments (optional)
|
|
313
|
+
* @returns The transaction hash
|
|
314
|
+
*/
|
|
315
|
+
async writeToContract(moduleAddress, moduleName, functionName, args, typeArguments = []) {
|
|
316
|
+
(0, utils_1.required)(this.account, "Wallet not connected");
|
|
317
|
+
try {
|
|
318
|
+
const transaction = await this.aptos.transaction.build.simple({
|
|
319
|
+
sender: this.account.accountAddress,
|
|
320
|
+
data: {
|
|
321
|
+
function: `${moduleAddress}::${moduleName}::${functionName}`,
|
|
322
|
+
typeArguments,
|
|
323
|
+
functionArguments: args
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
const response = await this.aptos.signAndSubmitTransaction({
|
|
327
|
+
signer: this.account,
|
|
328
|
+
transaction
|
|
329
|
+
});
|
|
330
|
+
return response.hash;
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
throw new Error(`Failed to write to contract: ${error}`);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Wait for transaction confirmation
|
|
338
|
+
* @param transactionHash The transaction hash
|
|
339
|
+
* @returns The transaction response
|
|
340
|
+
*/
|
|
341
|
+
async waitForTransaction(transactionHash) {
|
|
342
|
+
try {
|
|
343
|
+
return await this.aptos.waitForTransaction({
|
|
344
|
+
transactionHash
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
throw new Error(`Failed to wait for transaction: ${error}`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Check if an address is valid
|
|
353
|
+
* @param address The address to validate
|
|
354
|
+
* @returns Boolean indicating if the address is valid
|
|
355
|
+
*/
|
|
356
|
+
isAddress(address) {
|
|
357
|
+
try {
|
|
358
|
+
ts_sdk_1.AccountAddress.from(address);
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
exports.APTOS = APTOS;
|
|
367
|
+
//# 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;AA2DlC;;GAEG;AACH,MAAa,KAAM,SAAQ,2BAAY;IAMnC,YAAY,UAAkB,EAAE,EAAE,UAAmB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});
|
|
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
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
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 core_1 = require("../core");
|
|
6
|
+
const interfaces_1 = require("../core/types/interfaces");
|
|
7
|
+
/**
|
|
8
|
+
* Aptos LocalSDK implementation for Node.js environments
|
|
9
|
+
* Extends the core APTOS class with local-specific functionality
|
|
10
|
+
*/
|
|
11
|
+
class APTOS extends core_1.APTOS {
|
|
12
|
+
constructor(rpc_url = "", network = ts_sdk_1.Network.DEVNET) {
|
|
13
|
+
super(rpc_url, network);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Broadcasts a signed transaction to the Aptos network
|
|
17
|
+
* @param signed_tx The signed transaction (transaction hash as Uint8Array)
|
|
18
|
+
* @returns Transaction response with result and hash
|
|
19
|
+
*/
|
|
20
|
+
async sendTransaction(signed_tx) {
|
|
21
|
+
try {
|
|
22
|
+
// Convert Uint8Array back to transaction hash string
|
|
23
|
+
const transactionHash = new TextDecoder().decode(signed_tx);
|
|
24
|
+
// Wait for the transaction to be confirmed
|
|
25
|
+
const txResponse = await this.waitForTransaction(transactionHash);
|
|
26
|
+
return {
|
|
27
|
+
result: interfaces_1.XmTransactionResult.success,
|
|
28
|
+
hash: transactionHash,
|
|
29
|
+
extra: { txResponse }
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return {
|
|
34
|
+
result: interfaces_1.XmTransactionResult.error,
|
|
35
|
+
error: error.toString(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets network and node information
|
|
41
|
+
* @returns Network and ledger information
|
|
42
|
+
*/
|
|
43
|
+
async getInfo() {
|
|
44
|
+
try {
|
|
45
|
+
const [ledgerInfo, nodeInfo] = await Promise.all([
|
|
46
|
+
this.aptos.getLedgerInfo(),
|
|
47
|
+
this.aptos.getChainId()
|
|
48
|
+
]);
|
|
49
|
+
return {
|
|
50
|
+
network: this.network,
|
|
51
|
+
chainId: nodeInfo,
|
|
52
|
+
ledgerVersion: ledgerInfo.ledger_version,
|
|
53
|
+
ledgerTimestamp: ledgerInfo.ledger_timestamp,
|
|
54
|
+
nodeRole: ledgerInfo.node_role,
|
|
55
|
+
connected: this.connected
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new Error(`Failed to get network info: ${error}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates a new wallet (Account) with generated keys
|
|
64
|
+
* @param password Not used in Aptos SDK, kept for interface compatibility
|
|
65
|
+
* @returns The generated Account
|
|
66
|
+
*/
|
|
67
|
+
async createWallet(password) {
|
|
68
|
+
try {
|
|
69
|
+
// Generate new account using official SDK method
|
|
70
|
+
const newAccount = ts_sdk_1.Account.generate();
|
|
71
|
+
// Store as the current wallet
|
|
72
|
+
this.account = newAccount;
|
|
73
|
+
this.wallet = newAccount;
|
|
74
|
+
return newAccount;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw new Error(`Failed to create wallet: ${error}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gets the private key of the connected wallet
|
|
82
|
+
* @returns The private key as hex string
|
|
83
|
+
*/
|
|
84
|
+
getPrivateKey() {
|
|
85
|
+
if (!this.account) {
|
|
86
|
+
throw new Error("No wallet connected");
|
|
87
|
+
}
|
|
88
|
+
// In Aptos SDK, Account doesn't expose privateKey directly
|
|
89
|
+
// This would need to be stored separately when creating the account
|
|
90
|
+
throw new Error("Private key access not supported through Account object");
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Gets the public key of the connected wallet
|
|
94
|
+
* @returns The public key as hex string
|
|
95
|
+
*/
|
|
96
|
+
getPublicKey() {
|
|
97
|
+
if (!this.account) {
|
|
98
|
+
throw new Error("No wallet connected");
|
|
99
|
+
}
|
|
100
|
+
return this.account.publicKey.toString();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Fund account using faucet (only available on devnet/testnet)
|
|
104
|
+
* @param address The address to fund
|
|
105
|
+
* @param amount The amount to fund (in Octas)
|
|
106
|
+
* @returns The transaction hash
|
|
107
|
+
*/
|
|
108
|
+
async fundFromFaucet(address, amount = 100000000) {
|
|
109
|
+
try {
|
|
110
|
+
const accountAddress = address || this.getAddress();
|
|
111
|
+
if (this.network === ts_sdk_1.Network.MAINNET) {
|
|
112
|
+
throw new Error("Faucet not available on mainnet");
|
|
113
|
+
}
|
|
114
|
+
const response = await this.aptos.fundAccount({
|
|
115
|
+
accountAddress,
|
|
116
|
+
amount
|
|
117
|
+
});
|
|
118
|
+
return response.hash;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
throw new Error(`Failed to fund from faucet: ${error}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Submit a raw transaction (already signed)
|
|
126
|
+
* @param rawTransaction The raw transaction bytes
|
|
127
|
+
* @returns The transaction response
|
|
128
|
+
*/
|
|
129
|
+
async submitRawTransaction(rawTransaction) {
|
|
130
|
+
try {
|
|
131
|
+
// For Aptos, we expect the transaction to already be submitted
|
|
132
|
+
// This method is for compatibility with the existing multichain interface
|
|
133
|
+
const transactionHash = new TextDecoder().decode(rawTransaction);
|
|
134
|
+
const txResponse = await this.waitForTransaction(transactionHash);
|
|
135
|
+
return {
|
|
136
|
+
result: interfaces_1.XmTransactionResult.success,
|
|
137
|
+
hash: transactionHash,
|
|
138
|
+
extra: { txResponse }
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
return {
|
|
143
|
+
result: interfaces_1.XmTransactionResult.error,
|
|
144
|
+
error: error.toString(),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get transaction details by hash
|
|
150
|
+
* @param transactionHash The transaction hash
|
|
151
|
+
* @returns The transaction details
|
|
152
|
+
*/
|
|
153
|
+
async getTransaction(transactionHash) {
|
|
154
|
+
try {
|
|
155
|
+
return await this.aptos.getTransactionByHash({
|
|
156
|
+
transactionHash
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
throw new Error(`Failed to get transaction: ${error}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get account transactions
|
|
165
|
+
* @param address The account address
|
|
166
|
+
* @param start The start sequence number (optional)
|
|
167
|
+
* @param limit The maximum number of transactions to return (optional)
|
|
168
|
+
* @returns Array of transactions
|
|
169
|
+
*/
|
|
170
|
+
async getAccountTransactions(address, start, limit) {
|
|
171
|
+
try {
|
|
172
|
+
return await this.aptos.getAccountTransactions({
|
|
173
|
+
accountAddress: address,
|
|
174
|
+
options: {
|
|
175
|
+
offset: start,
|
|
176
|
+
limit
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
throw new Error(`Failed to get account transactions: ${error}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Estimate gas for a transaction
|
|
186
|
+
* @param transaction The transaction to estimate
|
|
187
|
+
* @returns Gas estimation
|
|
188
|
+
*/
|
|
189
|
+
async estimateGas(transaction) {
|
|
190
|
+
try {
|
|
191
|
+
return await this.aptos.transaction.simulate.simple({
|
|
192
|
+
signerPublicKey: this.account?.publicKey,
|
|
193
|
+
transaction
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
throw new Error(`Failed to estimate gas: ${error}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.APTOS = APTOS;
|
|
202
|
+
//# sourceMappingURL=aptos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aptos.js","sourceRoot":"","sources":["../../../../src/multichain/localsdk/aptos.ts"],"names":[],"mappings":";;;AAAA,+CAG2B;AAE3B,kCAGgB;AAChB,yDAAqF;AAErF;;;GAGG;AACH,MAAa,KAAM,SAAQ,YAAS;IAChC,YAAY,UAAkB,EAAE,EAAE,UAAmB,gBAAO,CAAC,MAAM;QAC/D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC3B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,eAAe,CAAC,SAAqB;QACvC,IAAI,CAAC;YACD,qDAAqD;YACrD,MAAM,eAAe,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAE3D,2CAA2C;YAC3C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;YAEjE,OAAO;gBACH,MAAM,EAAE,gCAAmB,CAAC,OAAO;gBACnC,IAAI,EAAE,eAAe;gBACrB,KAAK,EAAE,EAAE,UAAU,EAAE;aACxB,CAAA;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO;gBACH,MAAM,EAAE,gCAAmB,CAAC,KAAK;gBACjC,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE;aAC1B,CAAA;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO;QACT,IAAI,CAAC;YACD,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBAC7C,IAAI,CAAC,KAAK,CA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D,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC;gBACzC,eAAe;aAClB,CAAC,CAAA;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,EAAE,CAAC,CAAA;QAC1D,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,sBAAsB,CACxB,OAAe,EACf,KAAc,EACd,KAAc;QAEd,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC;gBAC3C,cAAc,EAAE,OAAO;gBACvB,OAAO,EAAE;oBACL,MAAM,EAAE,KAAK;oBACb,KAAK;iBACR;aACJ,CAAC,CAAA;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uCAAuC,KAAK,EAAE,CAAC,CAAA;QACnE,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,WAAgB;QAC9B,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAChD,eAAe,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS;gBACxC,WAAW;aACd,CAAC,CAAA;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAA;QACvD,CAAC;IACL,CAAC;CACJ;AA/MD,sBA+MC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BTC = exports.NEAR = exports.MULTIVERSX = exports.SOLANA = exports.TON = exports.IBC = exports.EVM = exports.XRPL = void 0;
|
|
3
|
+
exports.APTOS = exports.BTC = exports.NEAR = exports.MULTIVERSX = exports.SOLANA = exports.TON = exports.IBC = exports.EVM = exports.XRPL = void 0;
|
|
4
4
|
var xrp_1 = require("./xrp");
|
|
5
5
|
Object.defineProperty(exports, "XRPL", { enumerable: true, get: function () { return xrp_1.XRPL; } });
|
|
6
6
|
var evm_1 = require("./evm");
|
|
@@ -17,4 +17,6 @@ var near_1 = require("./near");
|
|
|
17
17
|
Object.defineProperty(exports, "NEAR", { enumerable: true, get: function () { return near_1.NEAR; } });
|
|
18
18
|
var btc_1 = require("./btc");
|
|
19
19
|
Object.defineProperty(exports, "BTC", { enumerable: true, get: function () { return btc_1.BTC; } });
|
|
20
|
+
var aptos_1 = require("./aptos");
|
|
21
|
+
Object.defineProperty(exports, "APTOS", { enumerable: true, get: function () { return aptos_1.APTOS; } });
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/multichain/localsdk/index.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAAnB,2FAAA,IAAI,OAAA;AACb,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AACnB,+BAA6B;AAApB,4FAAA,IAAI,OAAA;AACb,6BAA2B;AAAlB,0FAAA,GAAG,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/multichain/localsdk/index.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAAnB,2FAAA,IAAI,OAAA;AACb,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AACnB,+BAA6B;AAApB,4FAAA,IAAI,OAAA;AACb,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,iCAA+B;AAAtB,8FAAA,KAAK,OAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Network, Account } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import { APTOS as AptosCore, IDefaultChainWeb } from "../core";
|
|
3
|
+
/**
|
|
4
|
+
* Aptos WebSDK implementation for browser environments
|
|
5
|
+
* Extends the core APTOS class with browser-specific functionality
|
|
6
|
+
*/
|
|
7
|
+
export declare class APTOS extends AptosCore implements IDefaultChainWeb {
|
|
8
|
+
private walletAdapter;
|
|
9
|
+
constructor(rpc_url?: string, network?: Network);
|
|
10
|
+
/**
|
|
11
|
+
* Connect to a wallet. In browser environment, this can connect to wallet extensions
|
|
12
|
+
* or use a private key for direct connection.
|
|
13
|
+
* @param privateKey Optional private key for direct connection
|
|
14
|
+
* @returns The connected account or wallet adapter
|
|
15
|
+
*/
|
|
16
|
+
connectWallet(privateKey?: string): Promise<Account | any>;
|
|
17
|
+
/**
|
|
18
|
+
* Connect to a browser-based Aptos wallet (like Petra, Martian, etc.)
|
|
19
|
+
* @returns The wallet adapter
|
|
20
|
+
*/
|
|
21
|
+
private connectBrowserWallet;
|
|
22
|
+
/**
|
|
23
|
+
* Detect Petra wallet
|
|
24
|
+
*/
|
|
25
|
+
private detectPetraWallet;
|
|
26
|
+
/**
|
|
27
|
+
* Detect Martian wallet
|
|
28
|
+
*/
|
|
29
|
+
private detectMartianWallet;
|
|
30
|
+
/**
|
|
31
|
+
* Detect generic Aptos wallet
|
|
32
|
+
*/
|
|
33
|
+
private detectAptosWallet;
|
|
34
|
+
/**
|
|
35
|
+
* Connect to Petra wallet
|
|
36
|
+
*/
|
|
37
|
+
private connectPetraWallet;
|
|
38
|
+
/**
|
|
39
|
+
* Connect to Martian wallet
|
|
40
|
+
*/
|
|
41
|
+
private connectMartianWallet;
|
|
42
|
+
/**
|
|
43
|
+
* Connect to generic Aptos wallet
|
|
44
|
+
*/
|
|
45
|
+
private connectAptosWallet;
|
|
46
|
+
/**
|
|
47
|
+
* Get the wallet address (override for browser wallet compatibility)
|
|
48
|
+
*/
|
|
49
|
+
getAddress(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Sign a message using browser wallet or private key
|
|
52
|
+
*/
|
|
53
|
+
signMessage(message: string): Promise<Uint8Array>;
|
|
54
|
+
/**
|
|
55
|
+
* Sign and submit transaction using browser wallet or private key
|
|
56
|
+
*/
|
|
57
|
+
signTransaction(transaction: any): Promise<Uint8Array>;
|
|
58
|
+
/**
|
|
59
|
+
* Sign transaction without submitting (for wallet adapters that support it)
|
|
60
|
+
*/
|
|
61
|
+
signTransactionOnly(transaction: any): Promise<Uint8Array>;
|
|
62
|
+
/**
|
|
63
|
+
* Disconnect from wallet
|
|
64
|
+
*/
|
|
65
|
+
disconnect(): Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Check if wallet is connected
|
|
68
|
+
*/
|
|
69
|
+
isWalletConnected(): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Get connected wallet info
|
|
72
|
+
*/
|
|
73
|
+
getWalletInfo(): any;
|
|
74
|
+
/**
|
|
75
|
+
* Request wallet permissions (for some wallet adapters)
|
|
76
|
+
*/
|
|
77
|
+
requestPermissions(): Promise<any>;
|
|
78
|
+
/**
|
|
79
|
+
* Get network from wallet (if supported)
|
|
80
|
+
*/
|
|
81
|
+
getWalletNetwork(): Promise<any>;
|
|
82
|
+
/**
|
|
83
|
+
* Switch network in wallet (if supported)
|
|
84
|
+
*/
|
|
85
|
+
switchNetwork(network: Network): Promise<boolean>;
|
|
86
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
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 core_1 = require("../core");
|
|
6
|
+
/**
|
|
7
|
+
* Aptos WebSDK implementation for browser environments
|
|
8
|
+
* Extends the core APTOS class with browser-specific functionality
|
|
9
|
+
*/
|
|
10
|
+
class APTOS extends core_1.APTOS {
|
|
11
|
+
constructor(rpc_url = "", network = ts_sdk_1.Network.DEVNET) {
|
|
12
|
+
super(rpc_url, network);
|
|
13
|
+
this.walletAdapter = null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Connect to a wallet. In browser environment, this can connect to wallet extensions
|
|
17
|
+
* or use a private key for direct connection.
|
|
18
|
+
* @param privateKey Optional private key for direct connection
|
|
19
|
+
* @returns The connected account or wallet adapter
|
|
20
|
+
*/
|
|
21
|
+
async connectWallet(privateKey) {
|
|
22
|
+
// If private key is provided, use direct connection
|
|
23
|
+
if (privateKey) {
|
|
24
|
+
return await super.connectWallet(privateKey);
|
|
25
|
+
}
|
|
26
|
+
// Check for browser wallet adapters
|
|
27
|
+
if (typeof window !== "undefined") {
|
|
28
|
+
return await this.connectBrowserWallet();
|
|
29
|
+
}
|
|
30
|
+
throw new Error("No private key provided and no browser wallet available");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Connect to a browser-based Aptos wallet (like Petra, Martian, etc.)
|
|
34
|
+
* @returns The wallet adapter
|
|
35
|
+
*/
|
|
36
|
+
async connectBrowserWallet() {
|
|
37
|
+
try {
|
|
38
|
+
// Check for Petra wallet
|
|
39
|
+
if (this.detectPetraWallet()) {
|
|
40
|
+
return await this.connectPetraWallet();
|
|
41
|
+
}
|
|
42
|
+
// Check for Martian wallet
|
|
43
|
+
if (this.detectMartianWallet()) {
|
|
44
|
+
return await this.connectMartianWallet();
|
|
45
|
+
}
|
|
46
|
+
// Check for other Aptos wallets
|
|
47
|
+
if (this.detectAptosWallet()) {
|
|
48
|
+
return await this.connectAptosWallet();
|
|
49
|
+
}
|
|
50
|
+
throw new Error("No Aptos wallet detected. Please install Petra, Martian, or another Aptos wallet.");
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error(`Failed to connect browser wallet: ${error}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Detect Petra wallet
|
|
58
|
+
*/
|
|
59
|
+
detectPetraWallet() {
|
|
60
|
+
return typeof window !== "undefined" &&
|
|
61
|
+
"aptos" in window &&
|
|
62
|
+
window.aptos?.isPetra === true;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Detect Martian wallet
|
|
66
|
+
*/
|
|
67
|
+
detectMartianWallet() {
|
|
68
|
+
return typeof window !== "undefined" &&
|
|
69
|
+
"martian" in window;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Detect generic Aptos wallet
|
|
73
|
+
*/
|
|
74
|
+
detectAptosWallet() {
|
|
75
|
+
return typeof window !== "undefined" &&
|
|
76
|
+
"aptos" in window;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Connect to Petra wallet
|
|
80
|
+
*/
|
|
81
|
+
async connectPetraWallet() {
|
|
82
|
+
const wallet = window.aptos;
|
|
83
|
+
try {
|
|
84
|
+
const response = await wallet.connect();
|
|
85
|
+
this.walletAdapter = wallet;
|
|
86
|
+
this.connected = true;
|
|
87
|
+
// Create a mock account object for compatibility
|
|
88
|
+
this.account = {
|
|
89
|
+
accountAddress: response.address,
|
|
90
|
+
publicKey: response.publicKey,
|
|
91
|
+
// Note: Private key is not available from wallet adapters
|
|
92
|
+
};
|
|
93
|
+
this.wallet = this.walletAdapter;
|
|
94
|
+
return this.walletAdapter;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
throw new Error(`Failed to connect to Petra wallet: ${error}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Connect to Martian wallet
|
|
102
|
+
*/
|
|
103
|
+
async connectMartianWallet() {
|
|
104
|
+
const wallet = window.martian;
|
|
105
|
+
try {
|
|
106
|
+
const response = await wallet.connect();
|
|
107
|
+
this.walletAdapter = wallet;
|
|
108
|
+
this.connected = true;
|
|
109
|
+
this.account = {
|
|
110
|
+
accountAddress: response.address,
|
|
111
|
+
publicKey: response.publicKey,
|
|
112
|
+
};
|
|
113
|
+
this.wallet = this.walletAdapter;
|
|
114
|
+
return this.walletAdapter;
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
throw new Error(`Failed to connect to Martian wallet: ${error}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Connect to generic Aptos wallet
|
|
122
|
+
*/
|
|
123
|
+
async connectAptosWallet() {
|
|
124
|
+
const wallet = window.aptos;
|
|
125
|
+
try {
|
|
126
|
+
const response = await wallet.connect();
|
|
127
|
+
this.walletAdapter = wallet;
|
|
128
|
+
this.connected = true;
|
|
129
|
+
this.account = {
|
|
130
|
+
accountAddress: response.address,
|
|
131
|
+
publicKey: response.publicKey,
|
|
132
|
+
};
|
|
133
|
+
this.wallet = this.walletAdapter;
|
|
134
|
+
return this.walletAdapter;
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
throw new Error(`Failed to connect to Aptos wallet: ${error}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get the wallet address (override for browser wallet compatibility)
|
|
142
|
+
*/
|
|
143
|
+
getAddress() {
|
|
144
|
+
if (this.walletAdapter && this.account) {
|
|
145
|
+
return this.account.accountAddress.toString();
|
|
146
|
+
}
|
|
147
|
+
return super.getAddress();
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Sign a message using browser wallet or private key
|
|
151
|
+
*/
|
|
152
|
+
async signMessage(message) {
|
|
153
|
+
// If using wallet adapter
|
|
154
|
+
if (this.walletAdapter) {
|
|
155
|
+
try {
|
|
156
|
+
const response = await this.walletAdapter.signMessage({
|
|
157
|
+
message,
|
|
158
|
+
nonce: Date.now().toString() // Add nonce for security
|
|
159
|
+
});
|
|
160
|
+
return new TextEncoder().encode(response.signature);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
throw new Error(`Failed to sign message with wallet: ${error}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Fallback to private key signing
|
|
167
|
+
return super.signMessage(message);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Sign and submit transaction using browser wallet or private key
|
|
171
|
+
*/
|
|
172
|
+
async signTransaction(transaction) {
|
|
173
|
+
// If using wallet adapter
|
|
174
|
+
if (this.walletAdapter) {
|
|
175
|
+
try {
|
|
176
|
+
const response = await this.walletAdapter.signAndSubmitTransaction(transaction);
|
|
177
|
+
return new TextEncoder().encode(response.hash);
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
throw new Error(`Failed to sign transaction with wallet: ${error}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Fallback to private key signing
|
|
184
|
+
return super.signTransaction(transaction);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Sign transaction without submitting (for wallet adapters that support it)
|
|
188
|
+
*/
|
|
189
|
+
async signTransactionOnly(transaction) {
|
|
190
|
+
if (this.walletAdapter && this.walletAdapter.signTransaction) {
|
|
191
|
+
try {
|
|
192
|
+
const signedTx = await this.walletAdapter.signTransaction(transaction);
|
|
193
|
+
return signedTx;
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
throw new Error(`Failed to sign transaction: ${error}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
throw new Error("Wallet does not support transaction signing without submission");
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Disconnect from wallet
|
|
203
|
+
*/
|
|
204
|
+
async disconnect() {
|
|
205
|
+
if (this.walletAdapter && this.walletAdapter.disconnect) {
|
|
206
|
+
try {
|
|
207
|
+
await this.walletAdapter.disconnect();
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
console.warn("Error disconnecting wallet:", error);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
this.walletAdapter = null;
|
|
214
|
+
await super.disconnect();
|
|
215
|
+
return !this.connected;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Check if wallet is connected
|
|
219
|
+
*/
|
|
220
|
+
isWalletConnected() {
|
|
221
|
+
if (this.walletAdapter) {
|
|
222
|
+
return this.walletAdapter.isConnected === true;
|
|
223
|
+
}
|
|
224
|
+
return this.connected && this.account !== null;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get connected wallet info
|
|
228
|
+
*/
|
|
229
|
+
getWalletInfo() {
|
|
230
|
+
if (this.walletAdapter) {
|
|
231
|
+
return {
|
|
232
|
+
name: this.walletAdapter.name || "Unknown",
|
|
233
|
+
account: this.account,
|
|
234
|
+
isConnected: this.isWalletConnected()
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
name: "Direct Connection",
|
|
239
|
+
account: this.account,
|
|
240
|
+
isConnected: this.connected
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Request wallet permissions (for some wallet adapters)
|
|
245
|
+
*/
|
|
246
|
+
async requestPermissions() {
|
|
247
|
+
if (this.walletAdapter && this.walletAdapter.requestPermissions) {
|
|
248
|
+
return await this.walletAdapter.requestPermissions();
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get network from wallet (if supported)
|
|
254
|
+
*/
|
|
255
|
+
async getWalletNetwork() {
|
|
256
|
+
if (this.walletAdapter && this.walletAdapter.network) {
|
|
257
|
+
return this.walletAdapter.network();
|
|
258
|
+
}
|
|
259
|
+
return this.network;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Switch network in wallet (if supported)
|
|
263
|
+
*/
|
|
264
|
+
async switchNetwork(network) {
|
|
265
|
+
if (this.walletAdapter && this.walletAdapter.changeNetwork) {
|
|
266
|
+
try {
|
|
267
|
+
await this.walletAdapter.changeNetwork(network);
|
|
268
|
+
this.setNetwork(network);
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
console.error("Failed to switch network:", error);
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Fallback: just update local network
|
|
277
|
+
this.setNetwork(network);
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
exports.APTOS = APTOS;
|
|
282
|
+
//# sourceMappingURL=aptos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aptos.js","sourceRoot":"","sources":["../../../../src/multichain/websdk/aptos.ts"],"names":[],"mappings":";;;AAAA,+CAG2B;AAE3B,kCAAwE;AAExE;;;GAGG;AACH,MAAa,KAAM,SAAQ,YAAS;IAGhC,YAAY,UAAkB,EAAE,EAAE,UAAmB,gBAAO,CAAC,MAAM;QAC/D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAHnB,kBAAa,GAAQ,IAAI,CAAA;IAIjC,CAAC;IAED;;;;;OAKG;IACM,KAAK,CAAC,aAAa,CAAC,UAAmB;QAC5C,oDAAoD;QACpD,IAAI,UAAU,EAAE,CAAC;YACb,OAAO,MAAM,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;QAChD,CAAC;QAED,oCAAoC;QACpC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAA;QAC5C,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;IAC9E,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,oBAAoB;QAC9B,IAAI,CAAC;YACD,yBAAyB;YACzB,IAAI,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;gBAC3B,O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CAAC,CAAA;gBACxB,OAAO,IAAI,CAAA;YACf,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;gBACjD,OAAO,KAAK,CAAA;YAChB,CAAC;QACL,CAAC;QAED,sCAAsC;QACtC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACxB,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAjTD,sBAiTC"}
|
|
@@ -54,7 +54,7 @@ exports.SupportedTokens = {
|
|
|
54
54
|
USDT: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
|
55
55
|
},
|
|
56
56
|
SOLANA: {
|
|
57
|
-
NATIVE: "
|
|
57
|
+
NATIVE: "So11111111111111111111111111111111111111111",
|
|
58
58
|
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
59
59
|
USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
|
|
60
60
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/types/bridge/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC3B,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,KAAK;IACV,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;CACnB,CAAA;AAEY,QAAA,eAAe,GAAG;IAC3B,GAAG,EAAE;QACD,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,OAAO,EAAE;QACL,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,GAAG,EAAE;QACD,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,SAAS,EAAE;QACP,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,QAAQ,EAAE;QACN,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,QAAQ,EAAE;QACN,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,KAAK,EAAE;QACH,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,IAAI,EAAE;QACF,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,MAAM,EAAE;QACJ,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/types/bridge/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC3B,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,KAAK;IACV,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;CACnB,CAAA;AAEY,QAAA,eAAe,GAAG;IAC3B,GAAG,EAAE;QACD,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,OAAO,EAAE;QACL,MAAM,EAAE,4CAA4C;QACpD,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,4CAA4C;KACrD;IACD,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4,7 +4,6 @@ export { ISignature } from "./blockchain/ISignature";
|
|
|
4
4
|
export { RawTransaction } from "./blockchain/rawTransaction";
|
|
5
5
|
export { Transaction, TransactionContent, TransactionContentData, } from "./blockchain/Transaction";
|
|
6
6
|
export { L2PSTransaction, Web2Transaction, CrosschainTransaction, NativeTransaction, DemosworkTransaction, IdentityTransaction, InstantMessagingTransaction, NativeBridgeTransaction, SpecificTransaction, } from "./blockchain/TransactionSubtypes";
|
|
7
|
-
export { L2PSEncryptedPayload } from "../l2ps";
|
|
8
7
|
export { INativePayload } from "./native/INativePayload";
|
|
9
8
|
export { InstantMessagingPayload } from "./instantMessaging";
|
|
10
9
|
export { TxFee } from "./blockchain/TxFee";
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kynesyslabs/demosdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
|
+
"description": "Demosdk is a JavaScript/TypeScript SDK that provides a unified interface for interacting with Demos network",
|
|
4
5
|
"main": "build/index.js",
|
|
5
6
|
"types": "build/index.d.ts",
|
|
6
7
|
"author": "Kynesys Labs",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"test:evm": "rm -rf build && jest --testMatch '**/tests/**/evm.spec*.ts' --testPathIgnorePatterns **/tests/**/chainProvider* **/tests/utils/* **/tests/**/template* --verbose"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
51
|
+
"@aptos-labs/ts-sdk": "^1.28.0",
|
|
50
52
|
"@bitcoinerlab/secp256k1": "^1.2.0",
|
|
51
53
|
"@cosmjs/proto-signing": "^0.32.3",
|
|
52
54
|
"@cosmjs/stargate": "^0.32.3",
|