@weblock-wallet/sdk 0.1.47 → 0.1.48
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/index.cjs +90 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +90 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -106020,9 +106020,44 @@ var AssetService = class extends EventEmitter {
|
|
|
106020
106020
|
checkStatus();
|
|
106021
106021
|
}
|
|
106022
106022
|
async addToken(params) {
|
|
106023
|
+
const hasMeta = !!params.name && !!params.symbol && typeof params.decimals === "number";
|
|
106024
|
+
const meta = hasMeta ? {
|
|
106025
|
+
name: params.name,
|
|
106026
|
+
symbol: params.symbol,
|
|
106027
|
+
decimals: params.decimals
|
|
106028
|
+
} : await this.getTokenInfo({
|
|
106029
|
+
networkId: params.networkId,
|
|
106030
|
+
tokenAddress: params.address
|
|
106031
|
+
});
|
|
106032
|
+
try {
|
|
106033
|
+
await this.userClient.registerToken({
|
|
106034
|
+
blockchainId: params.networkId,
|
|
106035
|
+
contractAddress: params.address,
|
|
106036
|
+
name: meta.name,
|
|
106037
|
+
symbol: meta.symbol,
|
|
106038
|
+
decimals: meta.decimals
|
|
106039
|
+
});
|
|
106040
|
+
} catch (error) {
|
|
106041
|
+
throw new SDKError(
|
|
106042
|
+
"Failed to register token",
|
|
106043
|
+
"REQUEST_FAILED" /* REQUEST_FAILED */,
|
|
106044
|
+
error
|
|
106045
|
+
);
|
|
106046
|
+
}
|
|
106023
106047
|
const key = `${this.orgHost}:token:${params.networkId}:${params.address}`;
|
|
106024
106048
|
await LocalForage.save(key, params);
|
|
106025
106049
|
}
|
|
106050
|
+
async getRegisteredCoins(networkId) {
|
|
106051
|
+
try {
|
|
106052
|
+
return await this.userClient.getRegisteredCoins(networkId);
|
|
106053
|
+
} catch (error) {
|
|
106054
|
+
throw new SDKError(
|
|
106055
|
+
"Failed to get registered tokens",
|
|
106056
|
+
"REQUEST_FAILED" /* REQUEST_FAILED */,
|
|
106057
|
+
error
|
|
106058
|
+
);
|
|
106059
|
+
}
|
|
106060
|
+
}
|
|
106026
106061
|
async getTokenBalance(params) {
|
|
106027
106062
|
try {
|
|
106028
106063
|
const chainId = await this.resolveChainId(params.networkId);
|
|
@@ -106134,6 +106169,19 @@ var AssetService = class extends EventEmitter {
|
|
|
106134
106169
|
const key = `${this.orgHost}:nft:${params.networkId}:${params.address}`;
|
|
106135
106170
|
await LocalForage.save(key, params);
|
|
106136
106171
|
}
|
|
106172
|
+
// async checkSecurityTokenCompliance(params: {
|
|
106173
|
+
// networkId: string
|
|
106174
|
+
// tokenAddress: string
|
|
106175
|
+
// from: string
|
|
106176
|
+
// to: string
|
|
106177
|
+
// amount: string
|
|
106178
|
+
// }): Promise<{
|
|
106179
|
+
// canTransfer: boolean
|
|
106180
|
+
// reasons?: string[]
|
|
106181
|
+
// }> {
|
|
106182
|
+
// // TODO: Implement security token compliance check
|
|
106183
|
+
// return { canTransfer: true }
|
|
106184
|
+
// }
|
|
106137
106185
|
};
|
|
106138
106186
|
|
|
106139
106187
|
// src/core/internal.ts
|
|
@@ -106151,7 +106199,6 @@ var InternalCoreImpl = class {
|
|
|
106151
106199
|
getAddress: () => this.walletService.getAddress(),
|
|
106152
106200
|
create: (password) => this.walletService.create(password),
|
|
106153
106201
|
retrieveWallet: (password) => this.walletService.retrieveWallet(password),
|
|
106154
|
-
resetPin: (newPassword) => this.walletService.resetPin(newPassword),
|
|
106155
106202
|
getBalance: (address, chainId) => this.walletService.getBalance(address, chainId),
|
|
106156
106203
|
getTokenBalance: (tokenAddress, walletAddress, chainId) => this.walletService.getTokenBalance(tokenAddress, walletAddress, chainId),
|
|
106157
106204
|
sendTransaction: (params) => this.walletService.sendTransaction(params),
|
|
@@ -106173,25 +106220,27 @@ var InternalCoreImpl = class {
|
|
|
106173
106220
|
};
|
|
106174
106221
|
this.asset = {
|
|
106175
106222
|
transfer: (params) => this.assetService.transfer(params),
|
|
106176
|
-
|
|
106177
|
-
|
|
106178
|
-
* - InternalCore는 decimals?: number
|
|
106179
|
-
* - 기존 AssetService 내부 구현이 decimals를 string으로 받는 경우가 있어,
|
|
106180
|
-
* 여기서 안전하게 string으로 변환해서 전달합니다.
|
|
106181
|
-
*/
|
|
106182
|
-
addToken: (params) => this.assetService.addToken({
|
|
106183
|
-
...params,
|
|
106184
|
-
decimals: typeof params.decimals === "number" ? String(params.decimals) : void 0
|
|
106185
|
-
}),
|
|
106223
|
+
addToken: (params) => this.assetService.addToken(params),
|
|
106224
|
+
// New ERC20 methods
|
|
106186
106225
|
getTokenBalance: (params) => this.assetService.getTokenBalance(params),
|
|
106187
106226
|
approveToken: (params) => this.assetService.approveToken(params),
|
|
106188
106227
|
getAllowance: (params) => this.assetService.getAllowance(params),
|
|
106228
|
+
// getTokenInfo: (params: TokenInfoParams) =>
|
|
106229
|
+
// this.assetService.getTokenInfo(params),
|
|
106189
106230
|
addNFTCollection: (params) => this.assetService.addNFTCollection(params),
|
|
106231
|
+
// checkSecurityTokenCompliance: (params: {
|
|
106232
|
+
// networkId: string
|
|
106233
|
+
// tokenAddress: string
|
|
106234
|
+
// from: string
|
|
106235
|
+
// to: string
|
|
106236
|
+
// amount: string
|
|
106237
|
+
// }) => this.assetService.checkSecurityTokenCompliance(params),
|
|
106190
106238
|
on: (event, listener) => this.assetService.on(event, listener),
|
|
106191
106239
|
off: (event, listener) => this.assetService.off(event, listener),
|
|
106192
106240
|
getTokenInfo: (params) => this.assetService.getTokenInfo(params),
|
|
106193
106241
|
registerToken: (params) => this.assetService.registerToken(params),
|
|
106194
|
-
getTokenFullInfo: (params) => this.assetService.getTokenFullInfo(params)
|
|
106242
|
+
getTokenFullInfo: (params) => this.assetService.getTokenFullInfo(params),
|
|
106243
|
+
getRegisteredCoins: (networkId) => this.assetService.getRegisteredCoins(networkId)
|
|
106195
106244
|
};
|
|
106196
106245
|
const httpClient = new HttpClient(options);
|
|
106197
106246
|
const firebase = new FirebaseAuth(options);
|
|
@@ -106346,6 +106395,34 @@ var WalletModule = class {
|
|
|
106346
106395
|
network.chainId
|
|
106347
106396
|
);
|
|
106348
106397
|
console.log("\uCD5C\uADFC \uD2B8\uB79C\uC7AD\uC158:", latestTransaction);
|
|
106398
|
+
let tokens = [];
|
|
106399
|
+
try {
|
|
106400
|
+
const registered = await this.core.asset.getRegisteredCoins(network.id);
|
|
106401
|
+
if (registered?.length) {
|
|
106402
|
+
const unique = new Map(
|
|
106403
|
+
registered.map((c5) => [c5.contractAddress.toLowerCase(), c5])
|
|
106404
|
+
);
|
|
106405
|
+
tokens = await Promise.all(
|
|
106406
|
+
Array.from(unique.values()).map(async (coin) => {
|
|
106407
|
+
const full = await this.core.asset.getTokenFullInfo({
|
|
106408
|
+
networkId: network.id,
|
|
106409
|
+
tokenAddress: coin.contractAddress,
|
|
106410
|
+
walletAddress: address
|
|
106411
|
+
});
|
|
106412
|
+
return {
|
|
106413
|
+
...full,
|
|
106414
|
+
address: coin.contractAddress,
|
|
106415
|
+
name: coin.name ?? full.name,
|
|
106416
|
+
symbol: coin.symbol ?? full.symbol,
|
|
106417
|
+
decimals: typeof coin.decimals === "number" ? coin.decimals : full.decimals
|
|
106418
|
+
};
|
|
106419
|
+
})
|
|
106420
|
+
);
|
|
106421
|
+
}
|
|
106422
|
+
} catch (e7) {
|
|
106423
|
+
console.warn("Registered token load failed:", e7);
|
|
106424
|
+
tokens = [];
|
|
106425
|
+
}
|
|
106349
106426
|
const walletInfo = {
|
|
106350
106427
|
address,
|
|
106351
106428
|
network: {
|
|
@@ -106358,40 +106435,7 @@ var WalletModule = class {
|
|
|
106358
106435
|
balance: nativeBalance,
|
|
106359
106436
|
decimals: 18
|
|
106360
106437
|
},
|
|
106361
|
-
tokens
|
|
106362
|
-
// {
|
|
106363
|
-
// symbol: rbtBalance.symbol,
|
|
106364
|
-
// name: 'Real-estate Backed Token',
|
|
106365
|
-
// address: '0xB10536cC40Cb6E6415f70d3a4C1AF7Fa638AE829',
|
|
106366
|
-
// balance: rbtBalance,
|
|
106367
|
-
// decimals: rbtBalance.decimals,
|
|
106368
|
-
// totalSupply: rbtBalance,
|
|
106369
|
-
// },
|
|
106370
|
-
// {
|
|
106371
|
-
// symbol: usdrBalance.symbol,
|
|
106372
|
-
// name: 'USD Real-estate',
|
|
106373
|
-
// address: '0x8d335fe5B30e27F2B21F057a4766cf4BB8c30785',
|
|
106374
|
-
// balance: usdrBalance,
|
|
106375
|
-
// decimals: usdrBalance.decimals,
|
|
106376
|
-
// totalSupply: usdrBalance,
|
|
106377
|
-
// },
|
|
106378
|
-
// {
|
|
106379
|
-
// symbol: wftBalance.symbol,
|
|
106380
|
-
// name: 'WeBlock Foundation Token',
|
|
106381
|
-
// address: '0x6fa62Eda03956ef4E54f3C8597E8c3f3bE40A45B',
|
|
106382
|
-
// balance: wftBalance,
|
|
106383
|
-
// decimals: wftBalance.decimals,
|
|
106384
|
-
// totalSupply: wftBalance,
|
|
106385
|
-
// },
|
|
106386
|
-
// {
|
|
106387
|
-
// symbol: usdtBalance.symbol,
|
|
106388
|
-
// name: 'USD Tether',
|
|
106389
|
-
// address: '0xfF54B9ebe777f528E64C74bc95c68433B7546038',
|
|
106390
|
-
// balance: usdtBalance,
|
|
106391
|
-
// decimals: usdtBalance.decimals,
|
|
106392
|
-
// totalSupply: usdtBalance,
|
|
106393
|
-
// },
|
|
106394
|
-
],
|
|
106438
|
+
tokens,
|
|
106395
106439
|
nfts: [],
|
|
106396
106440
|
securities: []
|
|
106397
106441
|
},
|