@cryptorubic/web3 1.1.0-alpha-stellar.3 → 1.1.0-alpha-stellar.5
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/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export declare class StellarAdapter extends AbstractAdapter<StellarClient, Stell
|
|
|
29
29
|
contractAddress: string;
|
|
30
30
|
methodsData: MethodData[];
|
|
31
31
|
}[]): Promise<ContractMulticallResponse<Output>[][]>;
|
|
32
|
-
private
|
|
32
|
+
private convertTokenAddressToSAC;
|
|
33
33
|
read<T>(address: string, abi: any, method: string, methodArgs?: unknown[]): Promise<T>;
|
|
34
34
|
simulateTransaction(config: StellarTransactionConfig, from: string, timeout?: number): Promise<string>;
|
|
35
35
|
getTransactionStatus(srcTxHash: string): Promise<TxStatus>;
|
|
@@ -21,11 +21,17 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
async getTokensBalances(userAddress, tokensAddresses) {
|
|
24
|
-
const sacTokenAddresses = tokensAddresses.map((address) => address.startsWith('C') ? address : this.
|
|
24
|
+
const sacTokenAddresses = tokensAddresses.map((address) => address.startsWith('C') ? address : this.convertTokenAddressToSAC(address));
|
|
25
25
|
const balancePromises = sacTokenAddresses.map(async (contractId) => {
|
|
26
26
|
const contract = new stellar_sdk_1.Contract(contractId);
|
|
27
27
|
const operation = contract.call('balance', (0, stellar_sdk_1.nativeToScVal)(userAddress, { type: 'address' }));
|
|
28
|
-
const tx = new stellar_sdk_1.TransactionBuilder(new stellar_sdk_1.Account(userAddress, '0')
|
|
28
|
+
const tx = new stellar_sdk_1.TransactionBuilder(new stellar_sdk_1.Account(userAddress, '0'), {
|
|
29
|
+
fee: stellar_sdk_1.BASE_FEE,
|
|
30
|
+
networkPassphrase: stellar_sdk_1.Networks.PUBLIC
|
|
31
|
+
})
|
|
32
|
+
.addOperation(operation)
|
|
33
|
+
.setTimeout(30)
|
|
34
|
+
.build();
|
|
29
35
|
try {
|
|
30
36
|
const resp = await this.public.simulateTransaction(tx);
|
|
31
37
|
//@ts-ignore
|
|
@@ -64,10 +70,13 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
64
70
|
multicallContractsMethods(contractAbi, contractsData) {
|
|
65
71
|
throw new Error('Not Implemented ');
|
|
66
72
|
}
|
|
67
|
-
|
|
73
|
+
convertTokenAddressToSAC(tokenAddress) {
|
|
68
74
|
const [code, address] = tokenAddress === '0x0000000000000000000000000000000000000000' ? [stellar_sdk_1.Asset.native().code, undefined] : tokenAddress.split('-');
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
if (tokenAddress === '0x0000000000000000000000000000000000000000' || address?.startsWith('G')) {
|
|
76
|
+
const classicAsset = new stellar_sdk_1.Asset(code, address);
|
|
77
|
+
return classicAsset.contractId(stellar_sdk_1.Networks.PUBLIC);
|
|
78
|
+
}
|
|
79
|
+
return address;
|
|
71
80
|
}
|
|
72
81
|
async read(address, abi, method, methodArgs = []) {
|
|
73
82
|
// const operation = Operation.invokeHostFunction({
|