@cityofzion/bs-neo3 3.1.10 → 3.1.12
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/BSNeo3.d.ts +3 -2
- package/dist/BSNeo3.js +5 -5
- package/dist/services/blockchain-data/DoraBDSNeo3.js +5 -7
- package/dist/services/blockchain-data/RpcBDSNeo3.js +4 -12
- package/dist/services/claim/ClaimServiceNeo3.d.ts +1 -1
- package/dist/services/claim/ClaimServiceNeo3.js +4 -4
- package/dist/services/full-transactions-data/DoraFullTransactionsDataServiceNeo3.js +3 -3
- package/dist/services/neo3-neox-bridge/Neo3NeoXBridgeService.js +8 -11
- package/dist/services/vote/VoteServiceNeo3.js +3 -3
- package/dist/services/wallet-connect/WalletConnectServiceNeo3.d.ts +105 -38
- package/dist/services/wallet-connect/WalletConnectServiceNeo3.js +181 -75
- package/dist/types.d.ts +1 -0
- package/package.json +4 -3
package/dist/BSNeo3.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type IBlockchainDataService, type IExchangeDataService, type IExplorerService, type INftDataService, type ITokenService, type
|
|
1
|
+
import { type IBlockchainDataService, type IExchangeDataService, type IExplorerService, type INftDataService, type ITokenService, type TBSAccount, type TBSNetwork, type TBSToken, type TGetLedgerTransport, type TPingNetworkResponse, type TTransferParams, type IFullTransactionsDataService, type TTransactionDefault } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { NeonDappKitLedgerServiceNeo3 } from './services/ledger/NeonDappKitLedgerServiceNeo3';
|
|
3
3
|
import { Neo3NeoXBridgeService } from './services/neo3-neox-bridge/Neo3NeoXBridgeService';
|
|
4
4
|
import { VoteServiceNeo3 } from './services/vote/VoteServiceNeo3';
|
|
5
5
|
import type { IBSNeo3, TBSNeo3Name, TBSNeo3NetworkId } from './types';
|
|
6
6
|
import { api, wallet } from './helpers/BSNeo3NeonJsSingletonHelper';
|
|
7
|
+
import { WalletConnectServiceNeo3 } from './services/wallet-connect/WalletConnectServiceNeo3';
|
|
7
8
|
import { ClaimServiceNeo3 } from './services/claim/ClaimServiceNeo3';
|
|
8
9
|
export declare class BSNeo3 implements IBSNeo3 {
|
|
9
10
|
#private;
|
|
@@ -27,7 +28,7 @@ export declare class BSNeo3 implements IBSNeo3 {
|
|
|
27
28
|
neo3NeoXBridgeService: Neo3NeoXBridgeService;
|
|
28
29
|
tokenService: ITokenService;
|
|
29
30
|
claimService: ClaimServiceNeo3;
|
|
30
|
-
walletConnectService:
|
|
31
|
+
walletConnectService: WalletConnectServiceNeo3;
|
|
31
32
|
fullTransactionsDataService: IFullTransactionsDataService<TBSNeo3Name>;
|
|
32
33
|
constructor(network?: TBSNetwork<TBSNeo3NetworkId>, getLedgerTransport?: TGetLedgerTransport<TBSNeo3Name>);
|
|
33
34
|
setNetwork(network: TBSNetwork<TBSNeo3NetworkId>): void;
|
package/dist/BSNeo3.js
CHANGED
|
@@ -176,11 +176,11 @@ class BSNeo3 {
|
|
|
176
176
|
account: neonJsAccount,
|
|
177
177
|
});
|
|
178
178
|
const invocations = await __classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_buildTransferInvocation).call(this, params, neonJsAccount);
|
|
179
|
-
const {
|
|
179
|
+
const { networkFee, systemFee } = await invoker.calculateFee({
|
|
180
180
|
invocations,
|
|
181
181
|
signers: [],
|
|
182
182
|
});
|
|
183
|
-
return
|
|
183
|
+
return new blockchain_service_1.BSBigHumanAmount(networkFee, this.feeToken.decimals).plus(systemFee).toFormatted();
|
|
184
184
|
}
|
|
185
185
|
async transfer(params) {
|
|
186
186
|
const { senderAccount } = params;
|
|
@@ -226,8 +226,8 @@ class BSNeo3 {
|
|
|
226
226
|
txIdUrl: this.explorerService.buildTransactionUrl(txId),
|
|
227
227
|
date: new Date().toJSON(),
|
|
228
228
|
invocationCount: invocations.length,
|
|
229
|
-
networkFeeAmount: blockchain_service_1.
|
|
230
|
-
systemFeeAmount: blockchain_service_1.
|
|
229
|
+
networkFeeAmount: new blockchain_service_1.BSBigHumanAmount(fees.networkFee, this.feeToken.decimals).toFormatted(),
|
|
230
|
+
systemFeeAmount: new blockchain_service_1.BSBigHumanAmount(fees.systemFee, this.feeToken.decimals).toFormatted(),
|
|
231
231
|
view: 'default',
|
|
232
232
|
events,
|
|
233
233
|
data,
|
|
@@ -270,7 +270,7 @@ _BSNeo3_instances = new WeakSet(), _BSNeo3_setTokens = function _BSNeo3_setToken
|
|
|
270
270
|
{ type: 'Hash160', value: intent.receiverAddress },
|
|
271
271
|
{
|
|
272
272
|
type: 'Integer',
|
|
273
|
-
value: blockchain_service_1.
|
|
273
|
+
value: new blockchain_service_1.BSBigHumanAmount(intent.amount, intent.token.decimals).toUnit().toString(),
|
|
274
274
|
},
|
|
275
275
|
{ type: 'Any', value: null },
|
|
276
276
|
],
|
|
@@ -51,8 +51,8 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
51
51
|
txIdUrl,
|
|
52
52
|
block: response.block,
|
|
53
53
|
date: new Date(Number(response.time) * 1000).toJSON(),
|
|
54
|
-
systemFeeAmount: blockchain_service_1.
|
|
55
|
-
networkFeeAmount: blockchain_service_1.
|
|
54
|
+
systemFeeAmount: new blockchain_service_1.BSBigUnitAmount(response.sysfee, this._service.feeToken.decimals).toHuman().toFormatted(),
|
|
55
|
+
networkFeeAmount: new blockchain_service_1.BSBigUnitAmount(response.netfee, this._service.feeToken.decimals).toHuman().toFormatted(),
|
|
56
56
|
invocationCount: 0,
|
|
57
57
|
notificationCount: 0,
|
|
58
58
|
view: 'default',
|
|
@@ -89,8 +89,8 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
89
89
|
txIdUrl,
|
|
90
90
|
block: item.block,
|
|
91
91
|
date: new Date(Number(item.time) * 1000).toJSON(),
|
|
92
|
-
systemFeeAmount: blockchain_service_1.
|
|
93
|
-
networkFeeAmount: blockchain_service_1.
|
|
92
|
+
systemFeeAmount: new blockchain_service_1.BSBigUnitAmount(item.sysfee, this._service.feeToken.decimals).toHuman().toFormatted(),
|
|
93
|
+
networkFeeAmount: new blockchain_service_1.BSBigUnitAmount(item.netfee, this._service.feeToken.decimals).toHuman().toFormatted(),
|
|
94
94
|
invocationCount: 0,
|
|
95
95
|
notificationCount: notifications?.length ?? 0,
|
|
96
96
|
view: 'default',
|
|
@@ -158,9 +158,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
158
158
|
try {
|
|
159
159
|
const token = await this.getTokenInfo(balance.asset);
|
|
160
160
|
return {
|
|
161
|
-
amount: blockchain_service_1.
|
|
162
|
-
decimals: token.decimals,
|
|
163
|
-
}),
|
|
161
|
+
amount: new blockchain_service_1.BSBigHumanAmount(balance.balance, token.decimals).toFormatted(),
|
|
164
162
|
token,
|
|
165
163
|
};
|
|
166
164
|
}
|
|
@@ -59,12 +59,8 @@ class RpcBDSNeo3 {
|
|
|
59
59
|
txIdUrl,
|
|
60
60
|
block: response.validuntilblock,
|
|
61
61
|
date: new Date(Number(response.blocktime) * 1000).toJSON(),
|
|
62
|
-
systemFeeAmount: blockchain_service_1.
|
|
63
|
-
|
|
64
|
-
}),
|
|
65
|
-
networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(response.netfee ?? 0, this._service.feeToken.decimals), {
|
|
66
|
-
decimals: this._service.feeToken.decimals,
|
|
67
|
-
}),
|
|
62
|
+
systemFeeAmount: new blockchain_service_1.BSBigUnitAmount(response.sysfee, this._service.feeToken.decimals).toHuman().toFormatted(),
|
|
63
|
+
networkFeeAmount: new blockchain_service_1.BSBigUnitAmount(response.netfee, this._service.feeToken.decimals).toHuman().toFormatted(),
|
|
68
64
|
invocationCount: 0,
|
|
69
65
|
notificationCount: notifications.length,
|
|
70
66
|
view: 'default',
|
|
@@ -165,9 +161,7 @@ class RpcBDSNeo3 {
|
|
|
165
161
|
// Empty Block
|
|
166
162
|
}
|
|
167
163
|
return {
|
|
168
|
-
amount: blockchain_service_1.
|
|
169
|
-
decimals: token.decimals,
|
|
170
|
-
}),
|
|
164
|
+
amount: new blockchain_service_1.BSBigUnitAmount(balance.amount, token.decimals).toHuman().toFormatted(),
|
|
171
165
|
token,
|
|
172
166
|
};
|
|
173
167
|
});
|
|
@@ -200,9 +194,7 @@ _RpcBDSNeo3_instances = new WeakSet(), _RpcBDSNeo3_convertByteStringToAddress =
|
|
|
200
194
|
const amount = properties[2].value || '0';
|
|
201
195
|
return {
|
|
202
196
|
eventType: 'token',
|
|
203
|
-
amount: blockchain_service_1.
|
|
204
|
-
decimals: token.decimals,
|
|
205
|
-
}),
|
|
197
|
+
amount: new blockchain_service_1.BSBigUnitAmount(amount, token.decimals).toHuman().toFormatted(),
|
|
206
198
|
methodName: 'transfer',
|
|
207
199
|
from: convertedFrom,
|
|
208
200
|
fromUrl,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IBSNeo3, TBSNeo3Name } from '../../types';
|
|
2
|
-
import type
|
|
2
|
+
import { type IClaimService, type TBSAccount, type TClaimServiceTransactionData, type TTransactionBase, type TTransactionDefault, type TTransactionDefaultEvent, type TTransactionDefaultTokenEvent } from '@cityofzion/blockchain-service';
|
|
3
3
|
export declare class ClaimServiceNeo3 implements IClaimService<TBSNeo3Name> {
|
|
4
4
|
#private;
|
|
5
5
|
readonly _service: IBSNeo3;
|
|
@@ -8,6 +8,7 @@ var _ClaimServiceNeo3_instances, _ClaimServiceNeo3_buildClaimParams;
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ClaimServiceNeo3 = void 0;
|
|
10
10
|
const BSNeo3NeonJsSingletonHelper_1 = require("../../helpers/BSNeo3NeonJsSingletonHelper");
|
|
11
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
11
12
|
const BSNeo3Constants_1 = require("../../constants/BSNeo3Constants");
|
|
12
13
|
class ClaimServiceNeo3 {
|
|
13
14
|
constructor(service) {
|
|
@@ -48,10 +49,10 @@ class ClaimServiceNeo3 {
|
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
async getUnclaimed(address) {
|
|
51
|
-
const { rpc
|
|
52
|
+
const { rpc } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
52
53
|
const rpcClient = new rpc.RPCClient(this._service.network.url);
|
|
53
54
|
const response = await rpcClient.getUnclaimedGas(address);
|
|
54
|
-
return
|
|
55
|
+
return new blockchain_service_1.BSBigUnitAmount(response, this.claimToken.decimals).toHuman().toFormatted();
|
|
55
56
|
}
|
|
56
57
|
async calculateFee(senderAccount) {
|
|
57
58
|
const claimParams = __classPrivateFieldGet(this, _ClaimServiceNeo3_instances, "m", _ClaimServiceNeo3_buildClaimParams).call(this, senderAccount);
|
|
@@ -62,8 +63,7 @@ class ClaimServiceNeo3 {
|
|
|
62
63
|
const claimEvent = await this._buildTransactionEvent(senderAccount.address);
|
|
63
64
|
const [transaction] = await this._service.transfer(claimParams);
|
|
64
65
|
transaction.events.push(claimEvent);
|
|
65
|
-
|
|
66
|
-
transaction.data = data;
|
|
66
|
+
transaction.data = { isClaim: true };
|
|
67
67
|
return transaction;
|
|
68
68
|
}
|
|
69
69
|
getTransactionData(transaction) {
|
|
@@ -68,7 +68,7 @@ class DoraFullTransactionsDataServiceNeo3 {
|
|
|
68
68
|
events.splice(eventIndex, 0, {
|
|
69
69
|
eventType: 'token',
|
|
70
70
|
amount: event.amount
|
|
71
|
-
? blockchain_service_1.
|
|
71
|
+
? new blockchain_service_1.BSBigHumanAmount(event.amount, token?.decimals ?? event.tokenDecimals).toFormatted()
|
|
72
72
|
: undefined,
|
|
73
73
|
methodName,
|
|
74
74
|
from,
|
|
@@ -108,10 +108,10 @@ class DoraFullTransactionsDataServiceNeo3 {
|
|
|
108
108
|
invocationCount: item.invocationCount,
|
|
109
109
|
notificationCount: item.notificationCount,
|
|
110
110
|
networkFeeAmount: networkFeeAmount
|
|
111
|
-
? blockchain_service_1.
|
|
111
|
+
? new blockchain_service_1.BSBigHumanAmount(networkFeeAmount, __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").feeToken.decimals).toFormatted()
|
|
112
112
|
: undefined,
|
|
113
113
|
systemFeeAmount: systemFeeAmount
|
|
114
|
-
? blockchain_service_1.
|
|
114
|
+
? new blockchain_service_1.BSBigHumanAmount(systemFeeAmount, __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").feeToken.decimals).toFormatted()
|
|
115
115
|
: undefined,
|
|
116
116
|
view: 'default',
|
|
117
117
|
events,
|
|
@@ -58,9 +58,7 @@ class Neo3NeoXBridgeService {
|
|
|
58
58
|
const { u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
59
59
|
return {
|
|
60
60
|
neo3NeoxBridge: {
|
|
61
|
-
amount: blockchain_service_1.
|
|
62
|
-
decimals: tokenToUse.decimals,
|
|
63
|
-
}),
|
|
61
|
+
amount: new blockchain_service_1.BSBigUnitAmount(amountInDecimals, tokenToUse.decimals).toHuman().toFormatted(),
|
|
64
62
|
tokenToUse,
|
|
65
63
|
receiverAddress: `0x${u.HexString.fromBase64(byteStringReceiverAddress).toLittleEndian()}`,
|
|
66
64
|
},
|
|
@@ -110,12 +108,11 @@ class Neo3NeoXBridgeService {
|
|
|
110
108
|
!TypeChecker.isStackTypeInteger(minDepositItem) ||
|
|
111
109
|
!TypeChecker.isStackTypeInteger(maxDepositItem))
|
|
112
110
|
throw new blockchain_service_1.BSError('Invalid response', 'INVALID_RESPONSE');
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
const bridgeMaxAmount = blockchain_service_1.BSBigNumberHelper.format(maxAmountBn, { decimals: token.decimals });
|
|
111
|
+
const bridgeFee = new blockchain_service_1.BSBigUnitAmount(depositFeeItem.value, BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.decimals)
|
|
112
|
+
.toHuman()
|
|
113
|
+
.toFormatted();
|
|
114
|
+
const bridgeMinAmount = new blockchain_service_1.BSBigUnitAmount(minDepositItem.value, token.decimals).toHuman().toFormatted();
|
|
115
|
+
const bridgeMaxAmount = new blockchain_service_1.BSBigUnitAmount(maxDepositItem.value, token.decimals).toHuman().toFormatted();
|
|
119
116
|
return {
|
|
120
117
|
bridgeFee,
|
|
121
118
|
bridgeMinAmount,
|
|
@@ -142,11 +139,11 @@ class Neo3NeoXBridgeService {
|
|
|
142
139
|
{ type: 'Hash160', value: params.receiverAddress },
|
|
143
140
|
{
|
|
144
141
|
type: 'Integer',
|
|
145
|
-
value: blockchain_service_1.
|
|
142
|
+
value: new blockchain_service_1.BSBigHumanAmount(params.amount, params.token.decimals).toUnit().toString(),
|
|
146
143
|
},
|
|
147
144
|
{
|
|
148
145
|
type: 'Integer',
|
|
149
|
-
value: blockchain_service_1.
|
|
146
|
+
value: new blockchain_service_1.BSBigHumanAmount(params.bridgeFee, BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.decimals).toUnit().toString(),
|
|
150
147
|
},
|
|
151
148
|
],
|
|
152
149
|
};
|
|
@@ -115,8 +115,8 @@ class VoteServiceNeo3 {
|
|
|
115
115
|
txIdUrl: this._service.explorerService.buildTransactionUrl(txId),
|
|
116
116
|
date: new Date().toJSON(),
|
|
117
117
|
invocationCount,
|
|
118
|
-
networkFeeAmount: blockchain_service_1.
|
|
119
|
-
systemFeeAmount: blockchain_service_1.
|
|
118
|
+
networkFeeAmount: new blockchain_service_1.BSBigHumanAmount(fees.networkFee, feeDecimals).toFormatted(),
|
|
119
|
+
systemFeeAmount: new blockchain_service_1.BSBigHumanAmount(fees.systemFee, feeDecimals).toFormatted(),
|
|
120
120
|
view: 'default',
|
|
121
121
|
events: [claimEvent, voteEvent],
|
|
122
122
|
data,
|
|
@@ -135,7 +135,7 @@ class VoteServiceNeo3 {
|
|
|
135
135
|
});
|
|
136
136
|
const cim = __classPrivateFieldGet(this, _VoteServiceNeo3_instances, "m", _VoteServiceNeo3_buildVoteInvocation).call(this, { address: account.address, candidatePubKey });
|
|
137
137
|
const { total } = await invoker.calculateFee(cim);
|
|
138
|
-
return blockchain_service_1.
|
|
138
|
+
return new blockchain_service_1.BSBigHumanAmount(total, this._service.feeToken.decimals).toFormatted();
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
exports.VoteServiceNeo3 = VoteServiceNeo3;
|
|
@@ -1,45 +1,112 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { IBSNeo3, TBSNeo3Name } from '../../types';
|
|
3
|
-
|
|
1
|
+
import { type IWalletConnectService, type TWalletConnectServiceHandlers, type TWalletConnectServiceRequestMethodParams } from '@cityofzion/blockchain-service';
|
|
2
|
+
import type { IBSNeo3, TBSNeo3Name, TWalletConnectServiceNeo3Method } from '../../types';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
declare const contractInvocationParamsSchema: z.ZodObject<{
|
|
5
|
+
invocations: z.ZodArray<z.ZodObject<{
|
|
6
|
+
scriptHash: z.ZodString;
|
|
7
|
+
operation: z.ZodString;
|
|
8
|
+
args: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
|
+
type: z.ZodLiteral<"Any">;
|
|
10
|
+
value: z.ZodAny;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
type: z.ZodLiteral<"String">;
|
|
13
|
+
value: z.ZodString;
|
|
14
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
15
|
+
type: z.ZodLiteral<"Boolean">;
|
|
16
|
+
value: z.ZodBoolean;
|
|
17
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"PublicKey">;
|
|
19
|
+
value: z.ZodString;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
+
type: z.ZodLiteral<"Hash160">;
|
|
22
|
+
value: z.ZodString;
|
|
23
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"Hash256">;
|
|
25
|
+
value: z.ZodString;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
type: z.ZodLiteral<"Integer">;
|
|
28
|
+
value: z.ZodString;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
type: z.ZodLiteral<"ByteArray">;
|
|
31
|
+
value: z.ZodString;
|
|
32
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"Array">;
|
|
34
|
+
value: z.ZodArray<z.ZodAny>;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
36
|
+
type: z.ZodLiteral<"Map">;
|
|
37
|
+
value: z.ZodArray<z.ZodAny>;
|
|
38
|
+
}, z.core.$strip>], "type">>;
|
|
39
|
+
abortOnFail: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
signers: z.ZodArray<z.ZodObject<{
|
|
42
|
+
scopes: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
43
|
+
account: z.ZodOptional<z.ZodString>;
|
|
44
|
+
allowedContracts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
allowedGroups: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
46
|
+
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
47
|
+
action: z.ZodString;
|
|
48
|
+
condition: z.ZodAny;
|
|
49
|
+
}, z.core.$strip>>>;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
extraSystemFee: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
systemFeeOverride: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
extraNetworkFee: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
networkFeeOverride: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
declare const signMessageParamsSchema: z.ZodObject<{
|
|
57
|
+
message: z.ZodString;
|
|
58
|
+
version: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
declare const verifyMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
61
|
+
publicKey: z.ZodString;
|
|
62
|
+
data: z.ZodString;
|
|
63
|
+
salt: z.ZodOptional<z.ZodString>;
|
|
64
|
+
messageHex: z.ZodString;
|
|
65
|
+
message: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
+
publicKey: z.ZodString;
|
|
68
|
+
data: z.ZodString;
|
|
69
|
+
salt: z.ZodOptional<z.ZodString>;
|
|
70
|
+
message: z.ZodString;
|
|
71
|
+
messageHex: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>]>;
|
|
73
|
+
declare const encryptParamsSchema: z.ZodTuple<[z.ZodString, z.ZodOptional<z.ZodArray<z.ZodString>>], null>;
|
|
74
|
+
declare const decryptParamsSchema: z.ZodTuple<[z.ZodObject<{
|
|
75
|
+
randomVector: z.ZodString;
|
|
76
|
+
cipherText: z.ZodString;
|
|
77
|
+
dataTag: z.ZodString;
|
|
78
|
+
ephemPublicKey: z.ZodString;
|
|
79
|
+
}, z.core.$strip>], null>;
|
|
80
|
+
declare const decryptFromArrayParamsSchema: z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
81
|
+
randomVector: z.ZodString;
|
|
82
|
+
cipherText: z.ZodString;
|
|
83
|
+
dataTag: z.ZodString;
|
|
84
|
+
ephemPublicKey: z.ZodString;
|
|
85
|
+
}, z.core.$strip>>], null>;
|
|
86
|
+
declare const traverseIteratorParamsSchema: z.ZodTuple<[z.ZodString, z.ZodString, z.ZodNumber], null>;
|
|
87
|
+
export declare class WalletConnectServiceNeo3 implements IWalletConnectService<TBSNeo3Name, TWalletConnectServiceNeo3Method> {
|
|
4
88
|
#private;
|
|
5
89
|
readonly namespace: string;
|
|
6
90
|
readonly chain: string;
|
|
7
|
-
readonly supportedMethods:
|
|
91
|
+
readonly supportedMethods: TWalletConnectServiceNeo3Method[];
|
|
8
92
|
readonly supportedEvents: string[];
|
|
9
|
-
readonly calculableMethods:
|
|
10
|
-
readonly autoApproveMethods:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
nonce: number;
|
|
25
|
-
useragent: string;
|
|
26
|
-
protocol: {
|
|
27
|
-
addressversion: number;
|
|
28
|
-
network: number;
|
|
29
|
-
validatorscount: number;
|
|
30
|
-
msperblock: number;
|
|
31
|
-
maxtraceableblocks: number;
|
|
32
|
-
maxvaliduntilblockincrement: number;
|
|
33
|
-
maxtransactionsperblock: number;
|
|
34
|
-
memorypoolmaxtransactions: number;
|
|
35
|
-
initialgasdistribution: number;
|
|
36
|
-
};
|
|
37
|
-
rpcAddress: string;
|
|
38
|
-
}>;
|
|
39
|
-
calculateFee(args: TWalletConnectServiceRequestMethodParams<TBSNeo3Name>): Promise<import("@cityofzion/neon-dappkit-types/dist/Neo3Invoker").CalculateFee>;
|
|
40
|
-
signTransaction(args: TWalletConnectServiceRequestMethodParams<TBSNeo3Name>): Promise<import("@cityofzion/neon-dappkit-types/dist/Neo3Invoker").BuiltTransaction>;
|
|
41
|
-
getWalletInfo(args: TWalletConnectServiceRequestMethodParams<TBSNeo3Name>): Promise<{
|
|
42
|
-
isLedger: boolean;
|
|
93
|
+
readonly calculableMethods: TWalletConnectServiceNeo3Method[];
|
|
94
|
+
readonly autoApproveMethods: TWalletConnectServiceNeo3Method[];
|
|
95
|
+
handlers: TWalletConnectServiceHandlers<TBSNeo3Name, {
|
|
96
|
+
invokeFunction: z.infer<typeof contractInvocationParamsSchema>;
|
|
97
|
+
testInvoke: z.infer<typeof contractInvocationParamsSchema>;
|
|
98
|
+
signTransaction: z.infer<typeof contractInvocationParamsSchema>;
|
|
99
|
+
calculateFee: z.infer<typeof contractInvocationParamsSchema>;
|
|
100
|
+
signMessage: z.infer<typeof signMessageParamsSchema>;
|
|
101
|
+
verifyMessage: z.infer<typeof verifyMessageSchema>;
|
|
102
|
+
encrypt: z.infer<typeof encryptParamsSchema>;
|
|
103
|
+
decrypt: z.infer<typeof decryptParamsSchema>;
|
|
104
|
+
decryptFromArray: z.infer<typeof decryptFromArrayParamsSchema>;
|
|
105
|
+
getNetworkVersion: any;
|
|
106
|
+
traverseIterator: z.infer<typeof traverseIteratorParamsSchema>;
|
|
107
|
+
getWalletInfo: any;
|
|
43
108
|
}>;
|
|
109
|
+
constructor(service: IBSNeo3);
|
|
44
110
|
calculateRequestFee(args: TWalletConnectServiceRequestMethodParams<TBSNeo3Name>): Promise<string>;
|
|
45
111
|
}
|
|
112
|
+
export {};
|
|
@@ -10,28 +10,81 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _WalletConnectServiceNeo3_instances, _WalletConnectServiceNeo3_service, _WalletConnectServiceNeo3_getInvoker, _WalletConnectServiceNeo3_getSigner;
|
|
13
|
+
var _WalletConnectServiceNeo3_instances, _WalletConnectServiceNeo3_service, _WalletConnectServiceNeo3_invokeFunctionHandler, _WalletConnectServiceNeo3_testInvokeHandler, _WalletConnectServiceNeo3_signTransactionHandler, _WalletConnectServiceNeo3_calculateFeeHandler, _WalletConnectServiceNeo3_signMessageHandler, _WalletConnectServiceNeo3_verifyMessageHandler, _WalletConnectServiceNeo3_encryptHandler, _WalletConnectServiceNeo3_decryptHandler, _WalletConnectServiceNeo3_decryptFromArrayHandler, _WalletConnectServiceNeo3_getNetworkVersionHandler, _WalletConnectServiceNeo3_traverseIteratorHandler, _WalletConnectServiceNeo3_getWalletInfoHandler, _WalletConnectServiceNeo3_getInvoker, _WalletConnectServiceNeo3_getSigner;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.WalletConnectServiceNeo3 = void 0;
|
|
16
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
16
17
|
const BSNeo3NeonDappKitSingletonHelper_1 = require("../../helpers/BSNeo3NeonDappKitSingletonHelper");
|
|
17
18
|
const BSNeo3NeonJsSingletonHelper_1 = require("../../helpers/BSNeo3NeonJsSingletonHelper");
|
|
19
|
+
const zod_1 = require("zod");
|
|
20
|
+
const contractInvocationParamsSchema = zod_1.z.object({
|
|
21
|
+
invocations: zod_1.z.array(zod_1.z.object({
|
|
22
|
+
scriptHash: zod_1.z.string(),
|
|
23
|
+
operation: zod_1.z.string(),
|
|
24
|
+
args: zod_1.z.array(zod_1.z.discriminatedUnion('type', [
|
|
25
|
+
zod_1.z.object({ type: zod_1.z.literal('Any'), value: zod_1.z.any() }),
|
|
26
|
+
zod_1.z.object({ type: zod_1.z.literal('String'), value: zod_1.z.string() }),
|
|
27
|
+
zod_1.z.object({ type: zod_1.z.literal('Boolean'), value: zod_1.z.boolean() }),
|
|
28
|
+
zod_1.z.object({ type: zod_1.z.literal('PublicKey'), value: zod_1.z.string() }),
|
|
29
|
+
zod_1.z.object({ type: zod_1.z.literal('Hash160'), value: zod_1.z.string() }),
|
|
30
|
+
zod_1.z.object({ type: zod_1.z.literal('Hash256'), value: zod_1.z.string() }),
|
|
31
|
+
zod_1.z.object({ type: zod_1.z.literal('Integer'), value: zod_1.z.string() }),
|
|
32
|
+
zod_1.z.object({ type: zod_1.z.literal('ByteArray'), value: zod_1.z.string() }),
|
|
33
|
+
zod_1.z.object({ type: zod_1.z.literal('Array'), value: zod_1.z.array(zod_1.z.any()) }),
|
|
34
|
+
zod_1.z.object({ type: zod_1.z.literal('Map'), value: zod_1.z.array(zod_1.z.any()) }),
|
|
35
|
+
])),
|
|
36
|
+
abortOnFail: zod_1.z.boolean().optional(),
|
|
37
|
+
})),
|
|
38
|
+
signers: zod_1.z.array(zod_1.z.object({
|
|
39
|
+
scopes: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]),
|
|
40
|
+
account: zod_1.z.string().optional(),
|
|
41
|
+
allowedContracts: zod_1.z.array(zod_1.z.string()).optional(),
|
|
42
|
+
allowedGroups: zod_1.z.array(zod_1.z.string()).optional(),
|
|
43
|
+
rules: zod_1.z.array(zod_1.z.object({ action: zod_1.z.string(), condition: zod_1.z.any() })).optional(),
|
|
44
|
+
})),
|
|
45
|
+
extraSystemFee: zod_1.z.number().optional(),
|
|
46
|
+
systemFeeOverride: zod_1.z.number().optional(),
|
|
47
|
+
extraNetworkFee: zod_1.z.number().optional(),
|
|
48
|
+
networkFeeOverride: zod_1.z.number().optional(),
|
|
49
|
+
});
|
|
50
|
+
const signMessageParamsSchema = zod_1.z.object({
|
|
51
|
+
message: zod_1.z.string(),
|
|
52
|
+
version: zod_1.z.union([zod_1.z.literal(1), zod_1.z.literal(2), zod_1.z.literal(3)]).optional(),
|
|
53
|
+
});
|
|
54
|
+
const verifyMessageBaseParamsSchema = zod_1.z.object({
|
|
55
|
+
publicKey: zod_1.z.string(),
|
|
56
|
+
data: zod_1.z.string(),
|
|
57
|
+
salt: zod_1.z.string().optional(),
|
|
58
|
+
});
|
|
59
|
+
const verifyMessageSchema = zod_1.z.union([
|
|
60
|
+
verifyMessageBaseParamsSchema.extend({
|
|
61
|
+
messageHex: zod_1.z.string(),
|
|
62
|
+
message: zod_1.z.string().optional(),
|
|
63
|
+
}),
|
|
64
|
+
verifyMessageBaseParamsSchema.extend({
|
|
65
|
+
message: zod_1.z.string(),
|
|
66
|
+
messageHex: zod_1.z.string().optional(),
|
|
67
|
+
}),
|
|
68
|
+
]);
|
|
69
|
+
const encryptParamsSchema = zod_1.z.tuple([zod_1.z.string(), zod_1.z.array(zod_1.z.string()).optional()]);
|
|
70
|
+
const encryptedMessageSchema = zod_1.z.object({
|
|
71
|
+
randomVector: zod_1.z.string(),
|
|
72
|
+
cipherText: zod_1.z.string(),
|
|
73
|
+
dataTag: zod_1.z.string(),
|
|
74
|
+
ephemPublicKey: zod_1.z.string(),
|
|
75
|
+
});
|
|
76
|
+
const decryptParamsSchema = zod_1.z.tuple([encryptedMessageSchema]);
|
|
77
|
+
const decryptFromArrayParamsSchema = zod_1.z.tuple([zod_1.z.array(encryptedMessageSchema)]);
|
|
78
|
+
const traverseIteratorParamsSchema = zod_1.z.tuple([zod_1.z.string(), zod_1.z.string(), zod_1.z.number()]);
|
|
18
79
|
class WalletConnectServiceNeo3 {
|
|
19
80
|
constructor(service) {
|
|
20
81
|
_WalletConnectServiceNeo3_instances.add(this);
|
|
21
82
|
this.namespace = 'neo3';
|
|
83
|
+
// prettier-ignore
|
|
22
84
|
this.supportedMethods = [
|
|
23
|
-
'invokeFunction',
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'verifyMessage',
|
|
27
|
-
'getWalletInfo',
|
|
28
|
-
'traverseIterator',
|
|
29
|
-
'getNetworkVersion',
|
|
30
|
-
'encrypt',
|
|
31
|
-
'decrypt',
|
|
32
|
-
'decryptFromArray',
|
|
33
|
-
'calculateFee',
|
|
34
|
-
'signTransaction',
|
|
85
|
+
'invokeFunction', 'testInvoke', 'signMessage', 'verifyMessage',
|
|
86
|
+
'getWalletInfo', 'traverseIterator', 'getNetworkVersion', 'encrypt',
|
|
87
|
+
'decrypt', 'decryptFromArray', 'calculateFee', 'signTransaction',
|
|
35
88
|
];
|
|
36
89
|
this.supportedEvents = [];
|
|
37
90
|
this.calculableMethods = ['invokeFunction', 'signTransaction'];
|
|
@@ -43,76 +96,129 @@ class WalletConnectServiceNeo3 {
|
|
|
43
96
|
'calculateFee',
|
|
44
97
|
];
|
|
45
98
|
_WalletConnectServiceNeo3_service.set(this, void 0);
|
|
99
|
+
_WalletConnectServiceNeo3_invokeFunctionHandler.set(this, {
|
|
100
|
+
validate: async (params) => await contractInvocationParamsSchema.parseAsync(params),
|
|
101
|
+
process: async (args) => {
|
|
102
|
+
const invoker = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args.account);
|
|
103
|
+
return await invoker.invokeFunction(args.params);
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
_WalletConnectServiceNeo3_testInvokeHandler.set(this, {
|
|
107
|
+
validate: async (params) => await contractInvocationParamsSchema.parseAsync(params),
|
|
108
|
+
process: async (args) => {
|
|
109
|
+
const invoker = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args.account);
|
|
110
|
+
return await invoker.testInvoke(args.params);
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
_WalletConnectServiceNeo3_signTransactionHandler.set(this, {
|
|
114
|
+
validate: async (params) => await contractInvocationParamsSchema.parseAsync(params),
|
|
115
|
+
process: async (args) => {
|
|
116
|
+
const invoker = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args.account);
|
|
117
|
+
return await invoker.signTransaction(args.params);
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
_WalletConnectServiceNeo3_calculateFeeHandler.set(this, {
|
|
121
|
+
validate: async (params) => await contractInvocationParamsSchema.parseAsync(params),
|
|
122
|
+
process: async (args) => {
|
|
123
|
+
const invoker = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args.account);
|
|
124
|
+
return await invoker.calculateFee(args.params);
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
_WalletConnectServiceNeo3_signMessageHandler.set(this, {
|
|
128
|
+
validate: async (params) => await signMessageParamsSchema.parseAsync(params),
|
|
129
|
+
process: async (args) => {
|
|
130
|
+
const signer = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args.account);
|
|
131
|
+
return await signer.signMessage(args.params);
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
_WalletConnectServiceNeo3_verifyMessageHandler.set(this, {
|
|
135
|
+
validate: async (params) => await verifyMessageSchema.parseAsync(params),
|
|
136
|
+
process: async (args) => {
|
|
137
|
+
const signer = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args.account);
|
|
138
|
+
return await signer.verifyMessage(args.params);
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
_WalletConnectServiceNeo3_encryptHandler.set(this, {
|
|
142
|
+
validate: async (params) => await encryptParamsSchema.parseAsync(params),
|
|
143
|
+
process: async (args) => {
|
|
144
|
+
const signer = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args.account);
|
|
145
|
+
let publicKeys = args.params[1];
|
|
146
|
+
if (!publicKeys || publicKeys.length === 0) {
|
|
147
|
+
publicKeys = [signer.account.getPublicKey()];
|
|
148
|
+
}
|
|
149
|
+
return await signer.encrypt(args.params[0], publicKeys);
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
_WalletConnectServiceNeo3_decryptHandler.set(this, {
|
|
153
|
+
validate: async (params) => await decryptParamsSchema.parseAsync(params),
|
|
154
|
+
process: async (args) => {
|
|
155
|
+
const signer = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args.account);
|
|
156
|
+
return await signer.decrypt(args.params[0]);
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
_WalletConnectServiceNeo3_decryptFromArrayHandler.set(this, {
|
|
160
|
+
validate: async (params) => await decryptFromArrayParamsSchema.parseAsync(params),
|
|
161
|
+
process: async (args) => {
|
|
162
|
+
const signer = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args.account);
|
|
163
|
+
return await signer.decryptFromArray(args.params[0]);
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
_WalletConnectServiceNeo3_getNetworkVersionHandler.set(this, {
|
|
167
|
+
validate: async () => { },
|
|
168
|
+
process: async () => {
|
|
169
|
+
const { rpc } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
170
|
+
const rpcClient = new rpc.RPCClient(__classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.url);
|
|
171
|
+
const response = await rpcClient.getVersion();
|
|
172
|
+
return {
|
|
173
|
+
rpcAddress: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.url,
|
|
174
|
+
...response,
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
_WalletConnectServiceNeo3_traverseIteratorHandler.set(this, {
|
|
179
|
+
validate: async (params) => await traverseIteratorParamsSchema.parseAsync(params),
|
|
180
|
+
process: async (args) => {
|
|
181
|
+
const invoker = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args.account);
|
|
182
|
+
return await invoker.traverseIterator(args.params[0], args.params[1], args.params[2]);
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
_WalletConnectServiceNeo3_getWalletInfoHandler.set(this, {
|
|
186
|
+
validate: async () => { },
|
|
187
|
+
process: async (args) => {
|
|
188
|
+
return {
|
|
189
|
+
isLedger: args.account.isHardware || false,
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
});
|
|
46
193
|
__classPrivateFieldSet(this, _WalletConnectServiceNeo3_service, service, "f");
|
|
47
194
|
const networkId = service.network.type === 'custom' ? 'private' : __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.id.toString();
|
|
48
195
|
this.chain = `${this.namespace}:${networkId}`;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
async verifyMessage(args) {
|
|
63
|
-
const signer = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args);
|
|
64
|
-
return await signer.verifyMessage(args.params);
|
|
65
|
-
}
|
|
66
|
-
async traverseIterator(args) {
|
|
67
|
-
const invoker = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args);
|
|
68
|
-
return await invoker.traverseIterator(args.params[0], args.params[1], args.params[2]);
|
|
69
|
-
}
|
|
70
|
-
async decrypt(args) {
|
|
71
|
-
const signer = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args);
|
|
72
|
-
return await signer.decrypt(args.params[0]);
|
|
73
|
-
}
|
|
74
|
-
async encrypt(args) {
|
|
75
|
-
const signer = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args);
|
|
76
|
-
let publicKeys = args.params[1];
|
|
77
|
-
if (!publicKeys || publicKeys.length === 0) {
|
|
78
|
-
publicKeys = [signer.account.getPublicKey()];
|
|
79
|
-
}
|
|
80
|
-
return await signer.encrypt(args.params[0], publicKeys);
|
|
81
|
-
}
|
|
82
|
-
async decryptFromArray(args) {
|
|
83
|
-
const signer = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args);
|
|
84
|
-
return await signer.decryptFromArray(args.params[0]);
|
|
85
|
-
}
|
|
86
|
-
async getNetworkVersion() {
|
|
87
|
-
const { rpc } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
88
|
-
const rpcClient = new rpc.RPCClient(__classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.url);
|
|
89
|
-
const response = await rpcClient.getVersion();
|
|
90
|
-
return {
|
|
91
|
-
rpcAddress: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.url,
|
|
92
|
-
...response,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
async calculateFee(args) {
|
|
96
|
-
const invoker = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args);
|
|
97
|
-
return await invoker.calculateFee(args.params);
|
|
98
|
-
}
|
|
99
|
-
async signTransaction(args) {
|
|
100
|
-
const invoker = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args);
|
|
101
|
-
return await invoker.signTransaction(args.params);
|
|
102
|
-
}
|
|
103
|
-
async getWalletInfo(args) {
|
|
104
|
-
return {
|
|
105
|
-
isLedger: args.account.isHardware || false,
|
|
196
|
+
this.handlers = {
|
|
197
|
+
invokeFunction: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_invokeFunctionHandler, "f"),
|
|
198
|
+
testInvoke: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_testInvokeHandler, "f"),
|
|
199
|
+
signTransaction: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_signTransactionHandler, "f"),
|
|
200
|
+
calculateFee: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_calculateFeeHandler, "f"),
|
|
201
|
+
signMessage: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_signMessageHandler, "f"),
|
|
202
|
+
verifyMessage: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_verifyMessageHandler, "f"),
|
|
203
|
+
encrypt: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_encryptHandler, "f"),
|
|
204
|
+
decrypt: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_decryptHandler, "f"),
|
|
205
|
+
decryptFromArray: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_decryptFromArrayHandler, "f"),
|
|
206
|
+
getNetworkVersion: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_getNetworkVersionHandler, "f"),
|
|
207
|
+
traverseIterator: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_traverseIteratorHandler, "f"),
|
|
208
|
+
getWalletInfo: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_getWalletInfoHandler, "f"),
|
|
106
209
|
};
|
|
107
210
|
}
|
|
108
211
|
async calculateRequestFee(args) {
|
|
109
|
-
const
|
|
212
|
+
const params = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_calculateFeeHandler, "f").validate(args.params).catch(error => {
|
|
213
|
+
throw new blockchain_service_1.BSError('Params validation failed: ' + error.message, 'INVALID_PARAMS');
|
|
214
|
+
});
|
|
215
|
+
const { total } = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_calculateFeeHandler, "f").process({ ...args, params });
|
|
110
216
|
return total.toString();
|
|
111
217
|
}
|
|
112
218
|
}
|
|
113
219
|
exports.WalletConnectServiceNeo3 = WalletConnectServiceNeo3;
|
|
114
|
-
_WalletConnectServiceNeo3_service = new WeakMap(), _WalletConnectServiceNeo3_instances = new WeakSet(), _WalletConnectServiceNeo3_getInvoker = async function _WalletConnectServiceNeo3_getInvoker(
|
|
115
|
-
const { neonJsAccount, signingCallback } = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f")._generateSigningCallback(
|
|
220
|
+
_WalletConnectServiceNeo3_service = new WeakMap(), _WalletConnectServiceNeo3_invokeFunctionHandler = new WeakMap(), _WalletConnectServiceNeo3_testInvokeHandler = new WeakMap(), _WalletConnectServiceNeo3_signTransactionHandler = new WeakMap(), _WalletConnectServiceNeo3_calculateFeeHandler = new WeakMap(), _WalletConnectServiceNeo3_signMessageHandler = new WeakMap(), _WalletConnectServiceNeo3_verifyMessageHandler = new WeakMap(), _WalletConnectServiceNeo3_encryptHandler = new WeakMap(), _WalletConnectServiceNeo3_decryptHandler = new WeakMap(), _WalletConnectServiceNeo3_decryptFromArrayHandler = new WeakMap(), _WalletConnectServiceNeo3_getNetworkVersionHandler = new WeakMap(), _WalletConnectServiceNeo3_traverseIteratorHandler = new WeakMap(), _WalletConnectServiceNeo3_getWalletInfoHandler = new WeakMap(), _WalletConnectServiceNeo3_instances = new WeakSet(), _WalletConnectServiceNeo3_getInvoker = async function _WalletConnectServiceNeo3_getInvoker(account) {
|
|
221
|
+
const { neonJsAccount, signingCallback } = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f")._generateSigningCallback(account);
|
|
116
222
|
const { NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
117
223
|
const invoker = await NeonInvoker.init({
|
|
118
224
|
rpcAddress: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.url,
|
|
@@ -120,8 +226,8 @@ _WalletConnectServiceNeo3_service = new WeakMap(), _WalletConnectServiceNeo3_ins
|
|
|
120
226
|
signingCallback,
|
|
121
227
|
});
|
|
122
228
|
return invoker;
|
|
123
|
-
}, _WalletConnectServiceNeo3_getSigner = async function _WalletConnectServiceNeo3_getSigner(
|
|
124
|
-
const { neonJsAccount } = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f")._generateSigningCallback(
|
|
229
|
+
}, _WalletConnectServiceNeo3_getSigner = async function _WalletConnectServiceNeo3_getSigner(account) {
|
|
230
|
+
const { neonJsAccount } = await __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f")._generateSigningCallback(account);
|
|
125
231
|
const { NeonSigner } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
126
232
|
const signer = new NeonSigner(neonJsAccount);
|
|
127
233
|
return signer;
|
package/dist/types.d.ts
CHANGED
|
@@ -103,3 +103,4 @@ export type TRpcBDSNeo3Notification = {
|
|
|
103
103
|
eventname: string;
|
|
104
104
|
state: TRpcBDSNeo3NotificationState | TRpcBDSNeo3NotificationState[] | undefined;
|
|
105
105
|
};
|
|
106
|
+
export type TWalletConnectServiceNeo3Method = 'invokeFunction' | 'testInvoke' | 'signMessage' | 'verifyMessage' | 'getWalletInfo' | 'traverseIterator' | 'getNetworkVersion' | 'encrypt' | 'decrypt' | 'decryptFromArray' | 'calculateFee' | 'signTransaction';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.12",
|
|
4
4
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"author": "Coz",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@cityofzion/neon-dappkit": "~0.6.0",
|
|
20
20
|
"@cityofzion/neon-js": "~5.8.1",
|
|
21
21
|
"axios": "~1.15.0",
|
|
22
|
-
"@cityofzion/blockchain-service": "3.1.
|
|
22
|
+
"@cityofzion/blockchain-service": "3.1.12"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@cityofzion/neon-dappkit-types": "~0.5.0",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"dotenv": "~17.3.1",
|
|
30
30
|
"eslint": "~9.37.0",
|
|
31
31
|
"typescript": "~5.9.2",
|
|
32
|
-
"vitest": "~4.0.18"
|
|
32
|
+
"vitest": "~4.0.18",
|
|
33
|
+
"zod": "~4.3.6"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
36
|
"build": "rm -rf ./dist && rm -f *.tgz && npm run typecheck && tsc --project tsconfig.build.json",
|