@dynamic-labs-sdk/sui 0.1.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SuiNetworkProvider.types.d.ts.map +1 -0
- package/dist/SuiWalletAccount.types.d.ts.map +1 -0
- package/dist/SuiWalletProvider.types.d.ts.map +1 -0
- package/{src → dist}/addSuiExtension/addSuiExtension.d.ts +1 -1
- package/dist/addSuiExtension/addSuiExtension.d.ts.map +1 -0
- package/dist/addSuiExtension/index.d.ts.map +1 -0
- package/dist/addSuiWalletStandardExtension-CsaAXmct.esm.js +197 -0
- package/dist/addSuiWalletStandardExtension-CsaAXmct.esm.js.map +1 -0
- package/dist/addSuiWalletStandardExtension-rcQSzsTf.cjs.js +202 -0
- package/dist/addSuiWalletStandardExtension-rcQSzsTf.cjs.js.map +1 -0
- package/dist/addWaasSuiExtension-BiqnHHuw.esm.js +122 -0
- package/dist/addWaasSuiExtension-BiqnHHuw.esm.js.map +1 -0
- package/dist/addWaasSuiExtension-CxlX_a8e.cjs.js +127 -0
- package/dist/addWaasSuiExtension-CxlX_a8e.cjs.js.map +1 -0
- package/dist/errors/NotSuiProviderError/NotSuiProviderError.d.ts.map +1 -0
- package/dist/errors/NotSuiProviderError/index.d.ts.map +1 -0
- package/dist/exports/index.d.ts.map +1 -0
- package/dist/exports/waas.d.ts.map +1 -0
- package/dist/exports/walletStandard.d.ts.map +1 -0
- package/{src → dist}/getSuiClient/getSuiClient.d.ts +1 -1
- package/dist/getSuiClient/getSuiClient.d.ts.map +1 -0
- package/dist/getSuiClient/index.d.ts.map +1 -0
- package/dist/index.cjs.js +182 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm.js +174 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/isSuiNetworkProvider/index.d.ts.map +1 -0
- package/dist/isSuiNetworkProvider/isSuiNetworkProvider.d.ts.map +1 -0
- package/dist/isSuiWalletAccount/index.d.ts.map +1 -0
- package/dist/isSuiWalletAccount/isSuiWalletAccount.d.ts.map +1 -0
- package/dist/isSuiWalletProvider/index.d.ts.map +1 -0
- package/dist/isSuiWalletProvider/isSuiWalletProvider.d.ts.map +1 -0
- package/dist/registerSuiNetworkProviderBuilder/index.d.ts.map +1 -0
- package/dist/registerSuiNetworkProviderBuilder/registerSuiNetworkProviderBuilder.d.ts.map +1 -0
- package/dist/registerSuiNetworkProviderBuilder-9cPYr6qc.esm.js +44 -0
- package/dist/registerSuiNetworkProviderBuilder-9cPYr6qc.esm.js.map +1 -0
- package/dist/registerSuiNetworkProviderBuilder-CgFK-0xS.cjs.js +61 -0
- package/dist/registerSuiNetworkProviderBuilder-CgFK-0xS.cjs.js.map +1 -0
- package/dist/signAndExecuteTransaction/index.d.ts.map +1 -0
- package/{src → dist}/signAndExecuteTransaction/signAndExecuteTransaction.d.ts +1 -1
- package/dist/signAndExecuteTransaction/signAndExecuteTransaction.d.ts.map +1 -0
- package/dist/signAndExecuteTransactionBlock/index.d.ts.map +1 -0
- package/{src → dist}/signAndExecuteTransactionBlock/signAndExecuteTransactionBlock.d.ts +1 -1
- package/dist/signAndExecuteTransactionBlock/signAndExecuteTransactionBlock.d.ts.map +1 -0
- package/dist/signTransaction/index.d.ts.map +1 -0
- package/{src → dist}/signTransaction/signTransaction.d.ts +1 -1
- package/dist/signTransaction/signTransaction.d.ts.map +1 -0
- package/dist/signTransactionBlock/index.d.ts.map +1 -0
- package/{src → dist}/signTransactionBlock/signTransactionBlock.d.ts +1 -1
- package/dist/signTransactionBlock/signTransactionBlock.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/dist/utils/createSuiNetworkProvider/createSuiNetworkProvider.d.ts.map +1 -0
- package/dist/utils/createSuiNetworkProvider/index.d.ts.map +1 -0
- package/dist/utils/fetchSuiBalance/fetchSuiBalance.d.ts.map +1 -0
- package/dist/utils/fetchSuiBalance/index.d.ts.map +1 -0
- package/dist/waas/WaasSuiWalletProvider.types.d.ts.map +1 -0
- package/{src → dist}/waas/addWaasSuiExtension/addWaasSuiExtension.d.ts +1 -1
- package/dist/waas/addWaasSuiExtension/addWaasSuiExtension.d.ts.map +1 -0
- package/dist/waas/addWaasSuiExtension/index.d.ts.map +1 -0
- package/dist/waas/utils/createWalletProviderForWaasSui/createWalletProviderForWaasSui.d.ts.map +1 -0
- package/dist/waas/utils/createWalletProviderForWaasSui/index.d.ts.map +1 -0
- package/dist/waas.cjs.js +10 -0
- package/dist/waas.cjs.js.map +1 -0
- package/dist/waas.esm.js +10 -0
- package/dist/waas.esm.js.map +1 -0
- package/{src → dist}/walletStandard/addSuiWalletStandardExtension/addSuiWalletStandardExtension.d.ts +1 -1
- package/dist/walletStandard/addSuiWalletStandardExtension/addSuiWalletStandardExtension.d.ts.map +1 -0
- package/dist/walletStandard/addSuiWalletStandardExtension/index.d.ts.map +1 -0
- package/dist/walletStandard/utils/createWalletProviderFromSuiStandardWallet/createWalletProviderFromSuiStandardWallet.d.ts.map +1 -0
- package/dist/walletStandard/utils/createWalletProviderFromSuiStandardWallet/index.d.ts.map +1 -0
- package/dist/walletStandard.cjs.js +10 -0
- package/dist/walletStandard.cjs.js.map +1 -0
- package/dist/walletStandard.esm.js +10 -0
- package/dist/walletStandard.esm.js.map +1 -0
- package/package.json +30 -18
- package/CHANGELOG.md +0 -606
- package/addSuiWalletStandardExtension.cjs.js +0 -264
- package/addSuiWalletStandardExtension.esm.js +0 -262
- package/addWaasSuiExtension.cjs.js +0 -141
- package/addWaasSuiExtension.esm.js +0 -139
- package/index.cjs.d.ts +0 -1
- package/index.cjs.js +0 -193
- package/index.esm.d.ts +0 -1
- package/index.esm.js +0 -183
- package/registerSuiNetworkProviderBuilder.cjs.js +0 -62
- package/registerSuiNetworkProviderBuilder.esm.js +0 -57
- package/src/SuiNetworkProvider.types.d.ts.map +0 -1
- package/src/SuiWalletAccount.types.d.ts.map +0 -1
- package/src/SuiWalletProvider.types.d.ts.map +0 -1
- package/src/addSuiExtension/addSuiExtension.d.ts.map +0 -1
- package/src/addSuiExtension/index.d.ts.map +0 -1
- package/src/errors/NotSuiProviderError/NotSuiProviderError.d.ts.map +0 -1
- package/src/errors/NotSuiProviderError/index.d.ts.map +0 -1
- package/src/exports/index.d.ts.map +0 -1
- package/src/exports/waas.d.ts.map +0 -1
- package/src/exports/walletStandard.d.ts.map +0 -1
- package/src/getSuiClient/getSuiClient.d.ts.map +0 -1
- package/src/getSuiClient/index.d.ts.map +0 -1
- package/src/isSuiNetworkProvider/index.d.ts.map +0 -1
- package/src/isSuiNetworkProvider/isSuiNetworkProvider.d.ts.map +0 -1
- package/src/isSuiWalletAccount/index.d.ts.map +0 -1
- package/src/isSuiWalletAccount/isSuiWalletAccount.d.ts.map +0 -1
- package/src/isSuiWalletProvider/index.d.ts.map +0 -1
- package/src/isSuiWalletProvider/isSuiWalletProvider.d.ts.map +0 -1
- package/src/registerSuiNetworkProviderBuilder/index.d.ts.map +0 -1
- package/src/registerSuiNetworkProviderBuilder/registerSuiNetworkProviderBuilder.d.ts.map +0 -1
- package/src/signAndExecuteTransaction/index.d.ts.map +0 -1
- package/src/signAndExecuteTransaction/signAndExecuteTransaction.d.ts.map +0 -1
- package/src/signAndExecuteTransactionBlock/index.d.ts.map +0 -1
- package/src/signAndExecuteTransactionBlock/signAndExecuteTransactionBlock.d.ts.map +0 -1
- package/src/signTransaction/index.d.ts.map +0 -1
- package/src/signTransaction/signTransaction.d.ts.map +0 -1
- package/src/signTransactionBlock/index.d.ts.map +0 -1
- package/src/signTransactionBlock/signTransactionBlock.d.ts.map +0 -1
- package/src/utils/createSuiNetworkProvider/createSuiNetworkProvider.d.ts.map +0 -1
- package/src/utils/createSuiNetworkProvider/index.d.ts.map +0 -1
- package/src/utils/fetchSuiBalance/fetchSuiBalance.d.ts.map +0 -1
- package/src/utils/fetchSuiBalance/index.d.ts.map +0 -1
- package/src/waas/WaasSuiWalletProvider.types.d.ts.map +0 -1
- package/src/waas/addWaasSuiExtension/addWaasSuiExtension.d.ts.map +0 -1
- package/src/waas/addWaasSuiExtension/index.d.ts.map +0 -1
- package/src/waas/utils/createWalletProviderForWaasSui/createWalletProviderForWaasSui.d.ts.map +0 -1
- package/src/waas/utils/createWalletProviderForWaasSui/index.d.ts.map +0 -1
- package/src/walletStandard/addSuiWalletStandardExtension/addSuiWalletStandardExtension.d.ts.map +0 -1
- package/src/walletStandard/addSuiWalletStandardExtension/index.d.ts.map +0 -1
- package/src/walletStandard/utils/createWalletProviderFromSuiStandardWallet/createWalletProviderFromSuiStandardWallet.d.ts.map +0 -1
- package/src/walletStandard/utils/createWalletProviderFromSuiStandardWallet/index.d.ts.map +0 -1
- package/waas.cjs.d.ts +0 -1
- package/waas.cjs.js +0 -15
- package/waas.esm.d.ts +0 -1
- package/waas.esm.js +0 -11
- package/walletStandard.cjs.d.ts +0 -1
- package/walletStandard.cjs.js +0 -15
- package/walletStandard.esm.d.ts +0 -1
- package/walletStandard.esm.js +0 -11
- /package/{src → dist}/SuiNetworkProvider.types.d.ts +0 -0
- /package/{src → dist}/SuiWalletAccount.types.d.ts +0 -0
- /package/{src → dist}/SuiWalletProvider.types.d.ts +0 -0
- /package/{src → dist}/addSuiExtension/index.d.ts +0 -0
- /package/{src → dist}/errors/NotSuiProviderError/NotSuiProviderError.d.ts +0 -0
- /package/{src → dist}/errors/NotSuiProviderError/index.d.ts +0 -0
- /package/{src → dist}/exports/index.d.ts +0 -0
- /package/{src → dist}/exports/waas.d.ts +0 -0
- /package/{src → dist}/exports/walletStandard.d.ts +0 -0
- /package/{src → dist}/getSuiClient/index.d.ts +0 -0
- /package/{src → dist}/isSuiNetworkProvider/index.d.ts +0 -0
- /package/{src → dist}/isSuiNetworkProvider/isSuiNetworkProvider.d.ts +0 -0
- /package/{src → dist}/isSuiWalletAccount/index.d.ts +0 -0
- /package/{src → dist}/isSuiWalletAccount/isSuiWalletAccount.d.ts +0 -0
- /package/{src → dist}/isSuiWalletProvider/index.d.ts +0 -0
- /package/{src → dist}/isSuiWalletProvider/isSuiWalletProvider.d.ts +0 -0
- /package/{src → dist}/registerSuiNetworkProviderBuilder/index.d.ts +0 -0
- /package/{src → dist}/registerSuiNetworkProviderBuilder/registerSuiNetworkProviderBuilder.d.ts +0 -0
- /package/{src → dist}/signAndExecuteTransaction/index.d.ts +0 -0
- /package/{src → dist}/signAndExecuteTransactionBlock/index.d.ts +0 -0
- /package/{src → dist}/signTransaction/index.d.ts +0 -0
- /package/{src → dist}/signTransactionBlock/index.d.ts +0 -0
- /package/{src → dist}/utils/createSuiNetworkProvider/createSuiNetworkProvider.d.ts +0 -0
- /package/{src → dist}/utils/createSuiNetworkProvider/index.d.ts +0 -0
- /package/{src → dist}/utils/fetchSuiBalance/fetchSuiBalance.d.ts +0 -0
- /package/{src → dist}/utils/fetchSuiBalance/index.d.ts +0 -0
- /package/{src → dist}/waas/WaasSuiWalletProvider.types.d.ts +0 -0
- /package/{src → dist}/waas/addWaasSuiExtension/index.d.ts +0 -0
- /package/{src → dist}/waas/utils/createWalletProviderForWaasSui/createWalletProviderForWaasSui.d.ts +0 -0
- /package/{src → dist}/waas/utils/createWalletProviderForWaasSui/index.d.ts +0 -0
- /package/{src → dist}/walletStandard/addSuiWalletStandardExtension/index.d.ts +0 -0
- /package/{src → dist}/walletStandard/utils/createWalletProviderFromSuiStandardWallet/createWalletProviderFromSuiStandardWallet.d.ts +0 -0
- /package/{src → dist}/walletStandard/utils/createWalletProviderFromSuiStandardWallet/index.d.ts +0 -0
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { formatWalletProviderKey, formatWalletProviderGroupKey, switchActiveNetworkInLastKnownRegistry, getActiveNetworkIdFromLastKnownRegistry, getBuffer, assertDefined, getDefaultClient, hasExtension, registerExtension, getWalletProviderRegistry, WalletProviderPriority } from '@dynamic-labs-sdk/client/core';
|
|
2
|
-
import { _ as _extends, r as registerSuiNetworkProviderBuilder } from './registerSuiNetworkProviderBuilder.esm.js';
|
|
3
|
-
import { getActiveNetworkData } from '@dynamic-labs-sdk/client';
|
|
4
|
-
import { DYNAMIC_WAAS_METADATA, createWaasProvider, getAllUserWaasAddressesForChain } from '@dynamic-labs-sdk/client/waas/core';
|
|
5
|
-
import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
|
-
import { SuiClient } from '@mysten/sui/client';
|
|
7
|
-
|
|
8
|
-
const createWalletProviderForWaasSui = (sdkClient)=>{
|
|
9
|
-
const chain = 'SUI';
|
|
10
|
-
const walletProviderType = WalletProviderEnum.EmbeddedWallet;
|
|
11
|
-
const key = formatWalletProviderKey({
|
|
12
|
-
chain,
|
|
13
|
-
displayName: DYNAMIC_WAAS_METADATA.displayName,
|
|
14
|
-
walletProviderType
|
|
15
|
-
});
|
|
16
|
-
const waasProvider = createWaasProvider({
|
|
17
|
-
chain,
|
|
18
|
-
sdkClient
|
|
19
|
-
});
|
|
20
|
-
const getActiveNetworkId = async ()=>getActiveNetworkIdFromLastKnownRegistry({
|
|
21
|
-
client: sdkClient,
|
|
22
|
-
walletProviderKey: key
|
|
23
|
-
});
|
|
24
|
-
const getSuiClient = async ({ walletAccount })=>{
|
|
25
|
-
var _activeNetworkData_networkData;
|
|
26
|
-
const activeNetworkData = await getActiveNetworkData({
|
|
27
|
-
walletAccount
|
|
28
|
-
}, sdkClient);
|
|
29
|
-
assertDefined(activeNetworkData, 'No active network data found');
|
|
30
|
-
const url = (_activeNetworkData_networkData = activeNetworkData.networkData) == null ? void 0 : _activeNetworkData_networkData.rpcUrls.http[0];
|
|
31
|
-
assertDefined(url, 'No RPC URL found for active network');
|
|
32
|
-
return new SuiClient({
|
|
33
|
-
url
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
const switchActiveNetwork = async ({ networkId })=>switchActiveNetworkInLastKnownRegistry({
|
|
37
|
-
client: sdkClient,
|
|
38
|
-
networkId,
|
|
39
|
-
walletProviderKey: key
|
|
40
|
-
});
|
|
41
|
-
const getConnectedAddresses = async ()=>{
|
|
42
|
-
const waasSolanaAddresses = getAllUserWaasAddressesForChain({
|
|
43
|
-
chain
|
|
44
|
-
}, sdkClient);
|
|
45
|
-
return {
|
|
46
|
-
addresses: waasSolanaAddresses
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
const signAndExecuteTransaction = async ({ transaction, walletAccount })=>{
|
|
50
|
-
var _response_effects;
|
|
51
|
-
const { bytes, signature } = await signTransaction({
|
|
52
|
-
transaction,
|
|
53
|
-
walletAccount
|
|
54
|
-
});
|
|
55
|
-
const suiClient = await getSuiClient({
|
|
56
|
-
walletAccount
|
|
57
|
-
});
|
|
58
|
-
const response = await suiClient.executeTransactionBlock({
|
|
59
|
-
signature,
|
|
60
|
-
transactionBlock: bytes
|
|
61
|
-
});
|
|
62
|
-
var _response_effects_toString;
|
|
63
|
-
return _extends({}, response, {
|
|
64
|
-
bytes,
|
|
65
|
-
effects: (_response_effects_toString = (_response_effects = response.effects) == null ? void 0 : _response_effects.toString()) != null ? _response_effects_toString : '',
|
|
66
|
-
signature
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
const signTransaction = async ({ transaction, walletAccount })=>{
|
|
70
|
-
const suiClient = await getSuiClient({
|
|
71
|
-
walletAccount
|
|
72
|
-
});
|
|
73
|
-
const txBytes = await transaction.build({
|
|
74
|
-
client: suiClient
|
|
75
|
-
});
|
|
76
|
-
const txBytesBase64 = getBuffer().from(txBytes).toString('base64');
|
|
77
|
-
const txString = getBuffer().from(txBytes).toString('hex');
|
|
78
|
-
const { signature } = await waasProvider.signSerializedTransaction({
|
|
79
|
-
serializedTransaction: txString,
|
|
80
|
-
walletAccount
|
|
81
|
-
});
|
|
82
|
-
return {
|
|
83
|
-
bytes: txBytesBase64,
|
|
84
|
-
signature
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
const signMessage = async ({ message, walletAccount })=>{
|
|
88
|
-
assertDefined(walletAccount, 'Wallet account is required');
|
|
89
|
-
return waasProvider.signMessage({
|
|
90
|
-
message,
|
|
91
|
-
walletAccount
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
return _extends({}, waasProvider, {
|
|
95
|
-
chain,
|
|
96
|
-
getActiveNetworkId,
|
|
97
|
-
getConnectedAddresses,
|
|
98
|
-
getSuiClient,
|
|
99
|
-
groupKey: formatWalletProviderGroupKey(DYNAMIC_WAAS_METADATA.displayName),
|
|
100
|
-
key,
|
|
101
|
-
metadata: {
|
|
102
|
-
displayName: DYNAMIC_WAAS_METADATA.displayName,
|
|
103
|
-
icon: DYNAMIC_WAAS_METADATA.icon
|
|
104
|
-
},
|
|
105
|
-
signAndExecuteTransaction,
|
|
106
|
-
signMessage,
|
|
107
|
-
signTransaction,
|
|
108
|
-
switchActiveNetwork,
|
|
109
|
-
walletProviderType
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const WAAS_SUI_EXTENSION_KEY = 'waasSui';
|
|
114
|
-
/**
|
|
115
|
-
* Adds the Dynamic WaaS (Wallet as a Service) Sui extension to the Dynamic client.
|
|
116
|
-
*
|
|
117
|
-
* This extension enables embedded wallet functionality for Sui blockchain,
|
|
118
|
-
* allowing users to have wallets managed by Dynamic's infrastructure.
|
|
119
|
-
*
|
|
120
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
121
|
-
*/ const addWaasSuiExtension = (client = getDefaultClient())=>{
|
|
122
|
-
if (hasExtension({
|
|
123
|
-
extensionKey: WAAS_SUI_EXTENSION_KEY
|
|
124
|
-
}, client)) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
registerExtension({
|
|
128
|
-
extensionKey: WAAS_SUI_EXTENSION_KEY
|
|
129
|
-
}, client);
|
|
130
|
-
registerSuiNetworkProviderBuilder(client);
|
|
131
|
-
const walletProviderRegistry = getWalletProviderRegistry(client);
|
|
132
|
-
const walletProvider = createWalletProviderForWaasSui(client);
|
|
133
|
-
walletProviderRegistry.register({
|
|
134
|
-
priority: WalletProviderPriority.WALLET_SDK,
|
|
135
|
-
walletProvider
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export { addWaasSuiExtension as a };
|
package/index.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/exports/index";
|
package/index.cjs.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var assertPackageVersion = require('@dynamic-labs-sdk/assert-package-version');
|
|
4
|
-
var registerSuiNetworkProviderBuilder = require('./registerSuiNetworkProviderBuilder.cjs.js');
|
|
5
|
-
var core = require('@dynamic-labs-sdk/client/core');
|
|
6
|
-
var addWaasSuiExtension = require('./addWaasSuiExtension.cjs.js');
|
|
7
|
-
var addSuiWalletStandardExtension = require('./addSuiWalletStandardExtension.cjs.js');
|
|
8
|
-
var client = require('@dynamic-labs-sdk/client');
|
|
9
|
-
require('@mysten/sui/client');
|
|
10
|
-
require('@mysten/sui/utils');
|
|
11
|
-
require('@dynamic-labs-sdk/client/waas/core');
|
|
12
|
-
require('@dynamic-labs/sdk-api-core');
|
|
13
|
-
require('@mysten/wallet-standard');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Adds the Sui extension to the Dynamic client.
|
|
17
|
-
*
|
|
18
|
-
* This is a convenience function that adds both the Sui Wallet Standard extension
|
|
19
|
-
* and the Dynamic WaaS Sui extension, enabling support for all Sui wallet types
|
|
20
|
-
* including standard wallets and embedded wallets managed by Dynamic's infrastructure.
|
|
21
|
-
*
|
|
22
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
23
|
-
*/ const addSuiExtension = (client = core.getDefaultClient())=>{
|
|
24
|
-
addSuiWalletStandardExtension.addSuiWalletStandardExtension(client);
|
|
25
|
-
addWaasSuiExtension.addWaasSuiExtension(client);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
class NotSuiProviderError extends client.BaseError {
|
|
29
|
-
constructor(params){
|
|
30
|
-
super({
|
|
31
|
-
cause: null,
|
|
32
|
-
code: 'not_sui_provider_error',
|
|
33
|
-
docsUrl: null,
|
|
34
|
-
name: 'NotSuiProviderError',
|
|
35
|
-
shortMessage: 'Provider is not a Sui wallet provider'
|
|
36
|
-
});
|
|
37
|
-
this.providerKey = params.providerKey;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const isSuiWalletProvider = (provider)=>{
|
|
42
|
-
return provider.chain === 'SUI';
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Retrieves a SuiClient from a wallet account.
|
|
47
|
-
*
|
|
48
|
-
* @param params.walletAccount - The wallet account to get the SuiClient for.
|
|
49
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
50
|
-
* @returns A promise that resolves to a SuiClient instance
|
|
51
|
-
* @throws NotSuiProviderError If the wallet account's provider is not a SUI provider
|
|
52
|
-
*/ const getSuiClient = async ({ walletAccount }, client = core.getDefaultClient())=>{
|
|
53
|
-
const provider = core.getWalletProviderFromWalletAccount({
|
|
54
|
-
walletAccount
|
|
55
|
-
}, client);
|
|
56
|
-
if (!isSuiWalletProvider(provider)) {
|
|
57
|
-
throw new NotSuiProviderError({
|
|
58
|
-
providerKey: provider.key
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return provider.getSuiClient({
|
|
62
|
-
walletAccount
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Type guard function to check if a network provider is a Sui network provider.
|
|
68
|
-
*
|
|
69
|
-
* @param networkProvider - The network provider to check.
|
|
70
|
-
* @returns True if the network provider is a Sui network provider, false otherwise.
|
|
71
|
-
*/ const isSuiNetworkProvider = (networkProvider)=>networkProvider.chain === 'SUI';
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Type guard function to check if a wallet account is a Sui wallet account.
|
|
75
|
-
*
|
|
76
|
-
* @param walletAccount - The wallet account to check.
|
|
77
|
-
* @returns True if the wallet account is a Sui wallet account, false otherwise.
|
|
78
|
-
*/ const isSuiWalletAccount = (walletAccount)=>walletAccount.chain === 'SUI';
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Signs and executes a Sui transaction
|
|
82
|
-
* @param params.transaction - The transaction to sign and execute
|
|
83
|
-
* @param params.walletAccount - The wallet account to sign the transaction with
|
|
84
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
85
|
-
* @returns An object containing the signature and transaction bytes
|
|
86
|
-
*/ const signAndExecuteTransaction = async ({ walletAccount, transaction }, client$1 = client.getDefaultClient())=>{
|
|
87
|
-
const provider = core.getWalletProviderFromWalletAccount({
|
|
88
|
-
walletAccount
|
|
89
|
-
}, client$1);
|
|
90
|
-
if (!isSuiWalletProvider(provider)) {
|
|
91
|
-
throw new NotSuiProviderError({
|
|
92
|
-
providerKey: provider.key
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
transaction.setSender(walletAccount.address);
|
|
96
|
-
return provider.signAndExecuteTransaction({
|
|
97
|
-
transaction,
|
|
98
|
-
walletAccount
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @deprecated Use signAndExecuteTransaction instead
|
|
104
|
-
*
|
|
105
|
-
* Signs and executes a Sui transaction block
|
|
106
|
-
*
|
|
107
|
-
* @param params.transactionBlock - The transaction block to sign and execute
|
|
108
|
-
* @param params.walletAccount - The wallet account to sign the transaction with
|
|
109
|
-
* @param [params.options] - The fields to return in the execution response (e.g., transaction, effects, events, etc).
|
|
110
|
-
* By default, only the transaction digest will be returned.
|
|
111
|
-
* @param [params.requestType] - The request type to use for the transaction execution
|
|
112
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
113
|
-
* @returns An object containing signature result
|
|
114
|
-
*/ const signAndExecuteTransactionBlock = async ({ walletAccount, transactionBlock, options, requestType }, client$1 = client.getDefaultClient())=>{
|
|
115
|
-
const provider = core.getWalletProviderFromWalletAccount({
|
|
116
|
-
walletAccount
|
|
117
|
-
}, client$1);
|
|
118
|
-
if (!isSuiWalletProvider(provider)) {
|
|
119
|
-
throw new NotSuiProviderError({
|
|
120
|
-
providerKey: provider.key
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
if (!provider.signAndExecuteTransactionBlock) {
|
|
124
|
-
throw new core.MethodNotImplementedError('signAndExecuteTransactionBlock');
|
|
125
|
-
}
|
|
126
|
-
transactionBlock.setSender(walletAccount.address);
|
|
127
|
-
return provider.signAndExecuteTransactionBlock({
|
|
128
|
-
options,
|
|
129
|
-
requestType,
|
|
130
|
-
transactionBlock,
|
|
131
|
-
walletAccount
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Signs a Sui transaction
|
|
137
|
-
* @param params.transaction - The transaction to sign
|
|
138
|
-
* @param params.walletAccount - The wallet account to sign the transaction with
|
|
139
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
140
|
-
* @returns An object containing the signature and transaction bytes
|
|
141
|
-
*/ const signTransaction = async ({ walletAccount, transaction }, client$1 = client.getDefaultClient())=>{
|
|
142
|
-
const provider = core.getWalletProviderFromWalletAccount({
|
|
143
|
-
walletAccount
|
|
144
|
-
}, client$1);
|
|
145
|
-
if (!isSuiWalletProvider(provider)) {
|
|
146
|
-
throw new NotSuiProviderError({
|
|
147
|
-
providerKey: provider.key
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return provider.signTransaction({
|
|
151
|
-
transaction,
|
|
152
|
-
walletAccount
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* @deprecated Use signTransaction instead
|
|
158
|
-
*
|
|
159
|
-
* Signs a Sui transaction block
|
|
160
|
-
*
|
|
161
|
-
* @param params.transactionBlock - The transaction block to sign
|
|
162
|
-
* @param params.walletAccount - The wallet account to sign the transaction with
|
|
163
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
164
|
-
* @returns An object containing the signature and transaction block bytes
|
|
165
|
-
*/ const signTransactionBlock = async ({ walletAccount, transactionBlock }, client$1 = client.getDefaultClient())=>{
|
|
166
|
-
const provider = core.getWalletProviderFromWalletAccount({
|
|
167
|
-
walletAccount
|
|
168
|
-
}, client$1);
|
|
169
|
-
if (!isSuiWalletProvider(provider)) {
|
|
170
|
-
throw new NotSuiProviderError({
|
|
171
|
-
providerKey: provider.key
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
if (!provider.signTransactionBlock) {
|
|
175
|
-
throw new core.MethodNotImplementedError('signTransactionBlock');
|
|
176
|
-
}
|
|
177
|
-
return provider.signTransactionBlock({
|
|
178
|
-
transactionBlock,
|
|
179
|
-
walletAccount
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
assertPackageVersion.assertPackageVersion(registerSuiNetworkProviderBuilder.name, registerSuiNetworkProviderBuilder.version);
|
|
184
|
-
|
|
185
|
-
exports.NotSuiProviderError = NotSuiProviderError;
|
|
186
|
-
exports.addSuiExtension = addSuiExtension;
|
|
187
|
-
exports.getSuiClient = getSuiClient;
|
|
188
|
-
exports.isSuiNetworkProvider = isSuiNetworkProvider;
|
|
189
|
-
exports.isSuiWalletAccount = isSuiWalletAccount;
|
|
190
|
-
exports.signAndExecuteTransaction = signAndExecuteTransaction;
|
|
191
|
-
exports.signAndExecuteTransactionBlock = signAndExecuteTransactionBlock;
|
|
192
|
-
exports.signTransaction = signTransaction;
|
|
193
|
-
exports.signTransactionBlock = signTransactionBlock;
|
package/index.esm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/exports/index";
|
package/index.esm.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';
|
|
2
|
-
import { n as name, v as version } from './registerSuiNetworkProviderBuilder.esm.js';
|
|
3
|
-
import { getDefaultClient, getWalletProviderFromWalletAccount, MethodNotImplementedError } from '@dynamic-labs-sdk/client/core';
|
|
4
|
-
import { a as addWaasSuiExtension } from './addWaasSuiExtension.esm.js';
|
|
5
|
-
import { a as addSuiWalletStandardExtension } from './addSuiWalletStandardExtension.esm.js';
|
|
6
|
-
import { BaseError, getDefaultClient as getDefaultClient$1 } from '@dynamic-labs-sdk/client';
|
|
7
|
-
import '@mysten/sui/client';
|
|
8
|
-
import '@mysten/sui/utils';
|
|
9
|
-
import '@dynamic-labs-sdk/client/waas/core';
|
|
10
|
-
import '@dynamic-labs/sdk-api-core';
|
|
11
|
-
import '@mysten/wallet-standard';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Adds the Sui extension to the Dynamic client.
|
|
15
|
-
*
|
|
16
|
-
* This is a convenience function that adds both the Sui Wallet Standard extension
|
|
17
|
-
* and the Dynamic WaaS Sui extension, enabling support for all Sui wallet types
|
|
18
|
-
* including standard wallets and embedded wallets managed by Dynamic's infrastructure.
|
|
19
|
-
*
|
|
20
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
21
|
-
*/ const addSuiExtension = (client = getDefaultClient())=>{
|
|
22
|
-
addSuiWalletStandardExtension(client);
|
|
23
|
-
addWaasSuiExtension(client);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
class NotSuiProviderError extends BaseError {
|
|
27
|
-
constructor(params){
|
|
28
|
-
super({
|
|
29
|
-
cause: null,
|
|
30
|
-
code: 'not_sui_provider_error',
|
|
31
|
-
docsUrl: null,
|
|
32
|
-
name: 'NotSuiProviderError',
|
|
33
|
-
shortMessage: 'Provider is not a Sui wallet provider'
|
|
34
|
-
});
|
|
35
|
-
this.providerKey = params.providerKey;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const isSuiWalletProvider = (provider)=>{
|
|
40
|
-
return provider.chain === 'SUI';
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Retrieves a SuiClient from a wallet account.
|
|
45
|
-
*
|
|
46
|
-
* @param params.walletAccount - The wallet account to get the SuiClient for.
|
|
47
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
48
|
-
* @returns A promise that resolves to a SuiClient instance
|
|
49
|
-
* @throws NotSuiProviderError If the wallet account's provider is not a SUI provider
|
|
50
|
-
*/ const getSuiClient = async ({ walletAccount }, client = getDefaultClient())=>{
|
|
51
|
-
const provider = getWalletProviderFromWalletAccount({
|
|
52
|
-
walletAccount
|
|
53
|
-
}, client);
|
|
54
|
-
if (!isSuiWalletProvider(provider)) {
|
|
55
|
-
throw new NotSuiProviderError({
|
|
56
|
-
providerKey: provider.key
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return provider.getSuiClient({
|
|
60
|
-
walletAccount
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Type guard function to check if a network provider is a Sui network provider.
|
|
66
|
-
*
|
|
67
|
-
* @param networkProvider - The network provider to check.
|
|
68
|
-
* @returns True if the network provider is a Sui network provider, false otherwise.
|
|
69
|
-
*/ const isSuiNetworkProvider = (networkProvider)=>networkProvider.chain === 'SUI';
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Type guard function to check if a wallet account is a Sui wallet account.
|
|
73
|
-
*
|
|
74
|
-
* @param walletAccount - The wallet account to check.
|
|
75
|
-
* @returns True if the wallet account is a Sui wallet account, false otherwise.
|
|
76
|
-
*/ const isSuiWalletAccount = (walletAccount)=>walletAccount.chain === 'SUI';
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Signs and executes a Sui transaction
|
|
80
|
-
* @param params.transaction - The transaction to sign and execute
|
|
81
|
-
* @param params.walletAccount - The wallet account to sign the transaction with
|
|
82
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
83
|
-
* @returns An object containing the signature and transaction bytes
|
|
84
|
-
*/ const signAndExecuteTransaction = async ({ walletAccount, transaction }, client = getDefaultClient$1())=>{
|
|
85
|
-
const provider = getWalletProviderFromWalletAccount({
|
|
86
|
-
walletAccount
|
|
87
|
-
}, client);
|
|
88
|
-
if (!isSuiWalletProvider(provider)) {
|
|
89
|
-
throw new NotSuiProviderError({
|
|
90
|
-
providerKey: provider.key
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
transaction.setSender(walletAccount.address);
|
|
94
|
-
return provider.signAndExecuteTransaction({
|
|
95
|
-
transaction,
|
|
96
|
-
walletAccount
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated Use signAndExecuteTransaction instead
|
|
102
|
-
*
|
|
103
|
-
* Signs and executes a Sui transaction block
|
|
104
|
-
*
|
|
105
|
-
* @param params.transactionBlock - The transaction block to sign and execute
|
|
106
|
-
* @param params.walletAccount - The wallet account to sign the transaction with
|
|
107
|
-
* @param [params.options] - The fields to return in the execution response (e.g., transaction, effects, events, etc).
|
|
108
|
-
* By default, only the transaction digest will be returned.
|
|
109
|
-
* @param [params.requestType] - The request type to use for the transaction execution
|
|
110
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
111
|
-
* @returns An object containing signature result
|
|
112
|
-
*/ const signAndExecuteTransactionBlock = async ({ walletAccount, transactionBlock, options, requestType }, client = getDefaultClient$1())=>{
|
|
113
|
-
const provider = getWalletProviderFromWalletAccount({
|
|
114
|
-
walletAccount
|
|
115
|
-
}, client);
|
|
116
|
-
if (!isSuiWalletProvider(provider)) {
|
|
117
|
-
throw new NotSuiProviderError({
|
|
118
|
-
providerKey: provider.key
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
if (!provider.signAndExecuteTransactionBlock) {
|
|
122
|
-
throw new MethodNotImplementedError('signAndExecuteTransactionBlock');
|
|
123
|
-
}
|
|
124
|
-
transactionBlock.setSender(walletAccount.address);
|
|
125
|
-
return provider.signAndExecuteTransactionBlock({
|
|
126
|
-
options,
|
|
127
|
-
requestType,
|
|
128
|
-
transactionBlock,
|
|
129
|
-
walletAccount
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Signs a Sui transaction
|
|
135
|
-
* @param params.transaction - The transaction to sign
|
|
136
|
-
* @param params.walletAccount - The wallet account to sign the transaction with
|
|
137
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
138
|
-
* @returns An object containing the signature and transaction bytes
|
|
139
|
-
*/ const signTransaction = async ({ walletAccount, transaction }, client = getDefaultClient$1())=>{
|
|
140
|
-
const provider = getWalletProviderFromWalletAccount({
|
|
141
|
-
walletAccount
|
|
142
|
-
}, client);
|
|
143
|
-
if (!isSuiWalletProvider(provider)) {
|
|
144
|
-
throw new NotSuiProviderError({
|
|
145
|
-
providerKey: provider.key
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
return provider.signTransaction({
|
|
149
|
-
transaction,
|
|
150
|
-
walletAccount
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* @deprecated Use signTransaction instead
|
|
156
|
-
*
|
|
157
|
-
* Signs a Sui transaction block
|
|
158
|
-
*
|
|
159
|
-
* @param params.transactionBlock - The transaction block to sign
|
|
160
|
-
* @param params.walletAccount - The wallet account to sign the transaction with
|
|
161
|
-
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
162
|
-
* @returns An object containing the signature and transaction block bytes
|
|
163
|
-
*/ const signTransactionBlock = async ({ walletAccount, transactionBlock }, client = getDefaultClient$1())=>{
|
|
164
|
-
const provider = getWalletProviderFromWalletAccount({
|
|
165
|
-
walletAccount
|
|
166
|
-
}, client);
|
|
167
|
-
if (!isSuiWalletProvider(provider)) {
|
|
168
|
-
throw new NotSuiProviderError({
|
|
169
|
-
providerKey: provider.key
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
if (!provider.signTransactionBlock) {
|
|
173
|
-
throw new MethodNotImplementedError('signTransactionBlock');
|
|
174
|
-
}
|
|
175
|
-
return provider.signTransactionBlock({
|
|
176
|
-
transactionBlock,
|
|
177
|
-
walletAccount
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
assertPackageVersion(name, version);
|
|
182
|
-
|
|
183
|
-
export { NotSuiProviderError, addSuiExtension, getSuiClient, isSuiNetworkProvider, isSuiWalletAccount, signAndExecuteTransaction, signAndExecuteTransactionBlock, signTransaction, signTransactionBlock };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@dynamic-labs-sdk/client/core');
|
|
4
|
-
var client = require('@mysten/sui/client');
|
|
5
|
-
var utils = require('@mysten/sui/utils');
|
|
6
|
-
|
|
7
|
-
var name = "@dynamic-labs-sdk/sui";
|
|
8
|
-
var version = "0.1.2";
|
|
9
|
-
|
|
10
|
-
function _extends() {
|
|
11
|
-
_extends = Object.assign || function assign(target) {
|
|
12
|
-
for(var i = 1; i < arguments.length; i++){
|
|
13
|
-
var source = arguments[i];
|
|
14
|
-
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
15
|
-
}
|
|
16
|
-
return target;
|
|
17
|
-
};
|
|
18
|
-
return _extends.apply(this, arguments);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const fetchSuiBalance = async ({ address, rpcUrl })=>{
|
|
22
|
-
// Create a SuiClient using the provided RPC URL.
|
|
23
|
-
const suiClient = new client.SuiClient({
|
|
24
|
-
url: rpcUrl
|
|
25
|
-
});
|
|
26
|
-
const balanceInMist = await suiClient.getBalance({
|
|
27
|
-
owner: address
|
|
28
|
-
});
|
|
29
|
-
// Balance comes back as MIST, 1 SUI = 1e9 MIST
|
|
30
|
-
const balance = Number(balanceInMist.totalBalance) / Number(utils.MIST_PER_SUI);
|
|
31
|
-
if (Number.isNaN(balance)) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
return balance.toString();
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const createSuiNetworkProvider = (networkData)=>_extends({}, core.createBaseNetworkProvider('SUI', networkData), {
|
|
38
|
-
getBalance: async ({ address })=>({
|
|
39
|
-
balance: await fetchSuiBalance({
|
|
40
|
-
address,
|
|
41
|
-
rpcUrl: networkData.rpcUrls.http[0]
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const registerSuiNetworkProviderBuilder = (client)=>{
|
|
47
|
-
const networkProviderBuilderRegistry = core.getNetworkProviderBuilderRegistry(client);
|
|
48
|
-
/**
|
|
49
|
-
* If the Sui network provider builder is already registered, return.
|
|
50
|
-
*/ if (networkProviderBuilderRegistry.get().get('SUI')) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
networkProviderBuilderRegistry.register({
|
|
54
|
-
builder: createSuiNetworkProvider,
|
|
55
|
-
chain: 'SUI'
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
exports._extends = _extends;
|
|
60
|
-
exports.name = name;
|
|
61
|
-
exports.registerSuiNetworkProviderBuilder = registerSuiNetworkProviderBuilder;
|
|
62
|
-
exports.version = version;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { createBaseNetworkProvider, getNetworkProviderBuilderRegistry } from '@dynamic-labs-sdk/client/core';
|
|
2
|
-
import { SuiClient } from '@mysten/sui/client';
|
|
3
|
-
import { MIST_PER_SUI } from '@mysten/sui/utils';
|
|
4
|
-
|
|
5
|
-
var name = "@dynamic-labs-sdk/sui";
|
|
6
|
-
var version = "0.1.2";
|
|
7
|
-
|
|
8
|
-
function _extends() {
|
|
9
|
-
_extends = Object.assign || function assign(target) {
|
|
10
|
-
for(var i = 1; i < arguments.length; i++){
|
|
11
|
-
var source = arguments[i];
|
|
12
|
-
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
return _extends.apply(this, arguments);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const fetchSuiBalance = async ({ address, rpcUrl })=>{
|
|
20
|
-
// Create a SuiClient using the provided RPC URL.
|
|
21
|
-
const suiClient = new SuiClient({
|
|
22
|
-
url: rpcUrl
|
|
23
|
-
});
|
|
24
|
-
const balanceInMist = await suiClient.getBalance({
|
|
25
|
-
owner: address
|
|
26
|
-
});
|
|
27
|
-
// Balance comes back as MIST, 1 SUI = 1e9 MIST
|
|
28
|
-
const balance = Number(balanceInMist.totalBalance) / Number(MIST_PER_SUI);
|
|
29
|
-
if (Number.isNaN(balance)) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return balance.toString();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const createSuiNetworkProvider = (networkData)=>_extends({}, createBaseNetworkProvider('SUI', networkData), {
|
|
36
|
-
getBalance: async ({ address })=>({
|
|
37
|
-
balance: await fetchSuiBalance({
|
|
38
|
-
address,
|
|
39
|
-
rpcUrl: networkData.rpcUrls.http[0]
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const registerSuiNetworkProviderBuilder = (client)=>{
|
|
45
|
-
const networkProviderBuilderRegistry = getNetworkProviderBuilderRegistry(client);
|
|
46
|
-
/**
|
|
47
|
-
* If the Sui network provider builder is already registered, return.
|
|
48
|
-
*/ if (networkProviderBuilderRegistry.get().get('SUI')) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
networkProviderBuilderRegistry.register({
|
|
52
|
-
builder: createSuiNetworkProvider,
|
|
53
|
-
chain: 'SUI'
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export { _extends as _, name as n, registerSuiNetworkProviderBuilder as r, version as v };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SuiNetworkProvider.types.d.ts","sourceRoot":"","sources":["../../../../packages/sui/src/SuiNetworkProvider.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAE5D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,kBAAkB;QAC1B,GAAG,EAAE,kBAAkB,CAAC;KACzB;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SuiWalletAccount.types.d.ts","sourceRoot":"","sources":["../../../../packages/sui/src/SuiWalletAccount.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAExD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,gBAAgB;QACxB,GAAG,EAAE,gBAAgB,CAAC;KACvB;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SuiWalletProvider.types.d.ts","sourceRoot":"","sources":["../../../../packages/sui/src/SuiWalletProvider.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EACV,6BAA6B,EAC7B,SAAS,EACT,kCAAkC,EACnC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EACV,iBAAiB,EACjB,uCAAuC,EACvC,kCAAkC,EAClC,6BAA6B,EAC9B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EACV,uCAAuC,IAAI,uCAAuC,EAClF,kCAAkC,IAAI,kCAAkC,EACxE,6BAA6B,IAAI,6BAA6B,EAC9D,iBAAiB,IAAI,wBAAwB,GAC9C,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,6BAA6B,IAAI,gCAAgC,EACjE,kCAAkC,GACnC,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,wCAAwC,GAAG;IACrD,OAAO,CAAC,EAAE,kCAAkC,CAAC;IAC7C,WAAW,CAAC,EAAE,6BAA6B,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAC/C,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,CAAC,IAAI,EAAE;QACnB,aAAa,EAAE,gBAAgB,CAAC;KACjC,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;IACzB,yBAAyB,EAAE,CAAC,IAAI,EAAE;QAChC,WAAW,EAAE,WAAW,CAAC;QACzB,aAAa,EAAE,gBAAgB,CAAC;KACjC,KAAK,OAAO,CAAC,kCAAkC,CAAC,CAAC;IAClD,8BAA8B,CAAC,EAAE,CAAC,IAAI,EAAE;QACtC,OAAO,CAAC,EAAE,kCAAkC,CAAC;QAC7C,WAAW,CAAC,EAAE,6BAA6B,CAAC;QAC5C,gBAAgB,EAAE,WAAW,CAAC;QAC9B,aAAa,EAAE,gBAAgB,CAAC;KACjC,KAAK,OAAO,CAAC,uCAAuC,CAAC,CAAC;IACvD,eAAe,EAAE,CAAC,IAAI,EAAE;QACtB,WAAW,EAAE,WAAW,CAAC;QACzB,aAAa,EAAE,gBAAgB,CAAC;KACjC,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACjC,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE;QAC5B,gBAAgB,EAAE,WAAW,CAAC;QAC9B,aAAa,EAAE,gBAAgB,CAAC;KACjC,KAAK,OAAO,CAAC,6BAA6B,CAAC,CAAC;CAC9C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addSuiExtension.d.ts","sourceRoot":"","sources":["../../../../../packages/sui/src/addSuiExtension/addSuiExtension.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,oBAAkC,IAG7D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/sui/src/addSuiExtension/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotSuiProviderError.d.ts","sourceRoot":"","sources":["../../../../../../packages/sui/src/errors/NotSuiProviderError/NotSuiProviderError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,SAAgB,WAAW,EAAE,MAAM,CAAC;gBAExB,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE;CAW5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/sui/src/errors/NotSuiProviderError/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/sui/src/exports/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EACV,SAAS,EACT,gCAAgC,EAChC,uCAAuC,EACvC,kCAAkC,EAClC,6BAA6B,EAC7B,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,4BAA4B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"waas.d.ts","sourceRoot":"","sources":["../../../../../packages/sui/src/exports/waas.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
|