@cityofzion/bs-neo3 1.16.4 → 1.17.0

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { TBSAccount, TGetLedgerTransport, IBlockchainDataService, IClaimDataService, IExchangeDataService, IExplorerService, INeo3NeoXBridgeService, INftDataService, ITokenService, TBSNetwork, TBSToken, TTransferParam, TPingNetworkResponse } from '@cityofzion/blockchain-service';
1
+ import { TBSAccount, TGetLedgerTransport, IBlockchainDataService, IClaimDataService, IExchangeDataService, IExplorerService, INeo3NeoXBridgeService, INftDataService, ITokenService, TBSNetwork, TBSToken, TTransferParam, TPingNetworkResponse, IWalletConnectService } from '@cityofzion/blockchain-service';
2
2
  import { NeonDappKitLedgerServiceNeo3 } from './services/ledger/NeonDappKitLedgerServiceNeo3';
3
3
  import { IBSNeo3, IVoteService, TBSNeo3NetworkId } from './types';
4
4
  import { api, wallet } from './helpers/BSNeo3NeonJsSingletonHelper';
@@ -26,6 +26,7 @@ export declare class BSNeo3<N extends string = string> implements IBSNeo3<N> {
26
26
  neo3NeoXBridgeService: INeo3NeoXBridgeService<N>;
27
27
  tokenService: ITokenService;
28
28
  claimDataService: IClaimDataService;
29
+ walletConnectService: IWalletConnectService;
29
30
  constructor(name: N, network?: TBSNetwork<TBSNeo3NetworkId>, getLedgerTransport?: TGetLedgerTransport<N>);
30
31
  setNetwork(network: TBSNetwork<TBSNeo3NetworkId>): void;
31
32
  pingNetwork(network: TBSNetwork<TBSNeo3NetworkId>): Promise<TPingNetworkResponse>;
package/dist/BSNeo3.js CHANGED
@@ -34,6 +34,7 @@ const RpcCDSNeo3_1 = require("./services/chaim-data/RpcCDSNeo3");
34
34
  const BSNeo3NeonJsSingletonHelper_1 = require("./helpers/BSNeo3NeonJsSingletonHelper");
35
35
  const BSNeo3NeonDappKitSingletonHelper_1 = require("./helpers/BSNeo3NeonDappKitSingletonHelper");
36
36
  const axios_1 = __importDefault(require("axios"));
37
+ const WalletConnectServiceNeo3_1 = require("./services/wallet-connect/WalletConnectServiceNeo3");
37
38
  class BSNeo3 {
38
39
  constructor(name, network, getLedgerTransport) {
39
40
  _BSNeo3_instances.add(this);
@@ -74,6 +75,7 @@ class BSNeo3 {
74
75
  this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(this);
75
76
  this.exchangeDataService = new FlamingoForthewinEDSNeo3_1.FlamingoForthewinEDSNeo3(this);
76
77
  this.claimDataService = new RpcCDSNeo3_1.RpcCDSNeo3(this);
78
+ this.walletConnectService = new WalletConnectServiceNeo3_1.WalletConnectServiceNeo3(this);
77
79
  }
78
80
  // This method is done manually because we need to ensure that the request is aborted after timeout
79
81
  pingNetwork(network) {
package/dist/index.d.ts CHANGED
@@ -12,4 +12,5 @@ export * from './services/nft-data/GhostMarketNDSNeo3';
12
12
  export * from './services/vote/DoraVoteServiceNeo3';
13
13
  export * from './services/neo3neoXBridge/Neo3NeoXBridgeService';
14
14
  export * from './services/token/TokenServiceNeo3';
15
+ export * from './services/wallet-connect/WalletConnectServiceNeo3';
15
16
  export * from './types';
package/dist/index.js CHANGED
@@ -28,4 +28,5 @@ __exportStar(require("./services/nft-data/GhostMarketNDSNeo3"), exports);
28
28
  __exportStar(require("./services/vote/DoraVoteServiceNeo3"), exports);
29
29
  __exportStar(require("./services/neo3neoXBridge/Neo3NeoXBridgeService"), exports);
30
30
  __exportStar(require("./services/token/TokenServiceNeo3"), exports);
31
+ __exportStar(require("./services/wallet-connect/WalletConnectServiceNeo3"), exports);
31
32
  __exportStar(require("./types"), exports);
@@ -319,7 +319,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
319
319
  return token;
320
320
  }
321
321
  catch (_b) {
322
- throw new Error(`Token not found: ${tokenHash}`);
322
+ throw new Error(`TBSToken not found: ${tokenHash}`);
323
323
  }
324
324
  });
325
325
  }
@@ -0,0 +1,45 @@
1
+ import { IWalletConnectService, TWalletConnectServiceRequestMethodParams } from '@cityofzion/blockchain-service';
2
+ import { IBSNeo3 } from '../../types';
3
+ export declare class WalletConnectServiceNeo3<N extends string> implements IWalletConnectService {
4
+ #private;
5
+ readonly namespace: string;
6
+ readonly chain: string;
7
+ readonly supportedMethods: string[];
8
+ readonly supportedEvents: string[];
9
+ readonly calculableMethods: string[];
10
+ readonly autoApproveMethods: string[];
11
+ constructor(service: IBSNeo3<N>);
12
+ [methodName: string]: any;
13
+ invokeFunction(args: TWalletConnectServiceRequestMethodParams<N>): Promise<string>;
14
+ testInvoke(args: TWalletConnectServiceRequestMethodParams<N>): Promise<import("@cityofzion/neon-dappkit-types/dist/Neo3Invoker").InvokeResult<import("@cityofzion/neon-dappkit-types/dist/Neo3Invoker").RpcResponseStackItem>>;
15
+ signMessage(args: TWalletConnectServiceRequestMethodParams<N>): Promise<import("@cityofzion/neon-dappkit-types/dist/Neo3Signer").SignedMessage>;
16
+ verifyMessage(args: TWalletConnectServiceRequestMethodParams<N>): Promise<boolean>;
17
+ traverseIterator(args: TWalletConnectServiceRequestMethodParams<N>): Promise<import("@cityofzion/neon-dappkit-types/dist/Neo3Invoker").RpcResponseStackItem[]>;
18
+ decrypt(args: TWalletConnectServiceRequestMethodParams<N>): Promise<string>;
19
+ encrypt(args: TWalletConnectServiceRequestMethodParams<N>): Promise<import("@cityofzion/neon-dappkit-types/dist/Neo3Signer").EncryptedPayload[]>;
20
+ decryptFromArray(args: TWalletConnectServiceRequestMethodParams<N>): Promise<import("@cityofzion/neon-dappkit-types/dist/Neo3Signer").DecryptFromArrayResult>;
21
+ getNetworkVersion(): Promise<{
22
+ tcpport: number;
23
+ wsport: number;
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<N>): Promise<import("@cityofzion/neon-dappkit-types/dist/Neo3Invoker").CalculateFee>;
40
+ signTransaction(args: TWalletConnectServiceRequestMethodParams<N>): Promise<import("@cityofzion/neon-dappkit-types/dist/Neo3Invoker").BuiltTransaction>;
41
+ getWalletInfo(args: TWalletConnectServiceRequestMethodParams<N>): Promise<{
42
+ isLedger: boolean;
43
+ }>;
44
+ calculateRequestFee(args: TWalletConnectServiceRequestMethodParams<N>): Promise<string>;
45
+ }
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
+ 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");
20
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
+ };
22
+ var _WalletConnectServiceNeo3_instances, _WalletConnectServiceNeo3_service, _WalletConnectServiceNeo3_getInvoker, _WalletConnectServiceNeo3_getSigner;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.WalletConnectServiceNeo3 = void 0;
25
+ const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
26
+ const BSNeo3NeonDappKitSingletonHelper_1 = require("../../helpers/BSNeo3NeonDappKitSingletonHelper");
27
+ const BSNeo3NeonJsSingletonHelper_1 = require("../../helpers/BSNeo3NeonJsSingletonHelper");
28
+ class WalletConnectServiceNeo3 {
29
+ constructor(service) {
30
+ _WalletConnectServiceNeo3_instances.add(this);
31
+ this.namespace = 'neo3';
32
+ this.supportedMethods = [
33
+ 'invokeFunction',
34
+ 'testInvoke',
35
+ 'signMessage',
36
+ 'verifyMessage',
37
+ 'getWalletInfo',
38
+ 'traverseIterator',
39
+ 'getNetworkVersion',
40
+ 'encrypt',
41
+ 'decrypt',
42
+ 'decryptFromArray',
43
+ 'calculateFee',
44
+ 'signTransaction',
45
+ ];
46
+ this.supportedEvents = [];
47
+ this.calculableMethods = ['invokeFunction', 'signTransaction'];
48
+ this.autoApproveMethods = [
49
+ 'testInvoke',
50
+ 'getWalletInfo',
51
+ 'traverseIterator',
52
+ 'getNetworkVersion',
53
+ 'calculateFee',
54
+ ];
55
+ _WalletConnectServiceNeo3_service.set(this, void 0);
56
+ __classPrivateFieldSet(this, _WalletConnectServiceNeo3_service, service, "f");
57
+ const networkId = BSNeo3Helper_1.BSNeo3Helper.isCustomNetwork(__classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network)
58
+ ? 'private'
59
+ : __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.id.toString();
60
+ this.chain = `${this.namespace}:${networkId}`;
61
+ }
62
+ invokeFunction(args) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const invoker = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args);
65
+ return yield invoker.invokeFunction(args.params);
66
+ });
67
+ }
68
+ testInvoke(args) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const invoker = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args);
71
+ return yield invoker.testInvoke(args.params);
72
+ });
73
+ }
74
+ signMessage(args) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ const signer = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args);
77
+ return yield signer.signMessage(args.params);
78
+ });
79
+ }
80
+ verifyMessage(args) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ const signer = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args);
83
+ return yield signer.verifyMessage(args.params);
84
+ });
85
+ }
86
+ traverseIterator(args) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const invoker = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args);
89
+ return yield invoker.traverseIterator(args.params[0], args.params[1], args.params[2]);
90
+ });
91
+ }
92
+ decrypt(args) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const signer = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args);
95
+ return yield signer.decrypt(args.params[0]);
96
+ });
97
+ }
98
+ encrypt(args) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ const signer = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args);
101
+ return yield signer.encrypt(args.params[0], args.params[1]);
102
+ });
103
+ }
104
+ decryptFromArray(args) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ const signer = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getSigner).call(this, args);
107
+ return yield signer.decryptFromArray(args.params[0]);
108
+ });
109
+ }
110
+ getNetworkVersion() {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ const { rpc } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
113
+ const rpcClient = new rpc.RPCClient(__classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.url);
114
+ const response = yield rpcClient.getVersion();
115
+ return Object.assign({ rpcAddress: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.url }, response);
116
+ });
117
+ }
118
+ calculateFee(args) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ const invoker = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args);
121
+ return yield invoker.calculateFee(args.params);
122
+ });
123
+ }
124
+ signTransaction(args) {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const invoker = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_instances, "m", _WalletConnectServiceNeo3_getInvoker).call(this, args);
127
+ return yield invoker.signTransaction(args.params);
128
+ });
129
+ }
130
+ getWalletInfo(args) {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ return {
133
+ isLedger: args.account.isHardware || false,
134
+ };
135
+ });
136
+ }
137
+ calculateRequestFee(args) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ const { total } = yield this.calculateFee(args);
140
+ return total.toString();
141
+ });
142
+ }
143
+ }
144
+ exports.WalletConnectServiceNeo3 = WalletConnectServiceNeo3;
145
+ _WalletConnectServiceNeo3_service = new WeakMap(), _WalletConnectServiceNeo3_instances = new WeakSet(), _WalletConnectServiceNeo3_getInvoker = function _WalletConnectServiceNeo3_getInvoker(args) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const { neonJsAccount, signingCallback } = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").generateSigningCallback(args.account);
148
+ const { NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
149
+ const invoker = yield NeonInvoker.init({
150
+ rpcAddress: __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").network.url,
151
+ account: neonJsAccount,
152
+ signingCallback,
153
+ });
154
+ return invoker;
155
+ });
156
+ }, _WalletConnectServiceNeo3_getSigner = function _WalletConnectServiceNeo3_getSigner(args) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ const { neonJsAccount } = yield __classPrivateFieldGet(this, _WalletConnectServiceNeo3_service, "f").generateSigningCallback(args.account);
159
+ const { NeonSigner } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
160
+ const signer = new NeonSigner(neonJsAccount);
161
+ return signer;
162
+ });
163
+ };
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { TBSAccount, IBlockchainService, IBSWithClaim, IBSWithEncryption, IBSWithExplorer, IBSWithFee, IBSWithLedger, IBSWithNameService, IBSWithNeo3NeoXBridge, IBSWithNft, TBSNetworkId } from '@cityofzion/blockchain-service';
1
+ import { TBSAccount, IBlockchainService, IBSWithClaim, IBSWithEncryption, IBSWithExplorer, IBSWithFee, IBSWithLedger, IBSWithNameService, IBSWithNeo3NeoXBridge, IBSWithNft, TBSNetworkId, IBSWithWalletConnect } from '@cityofzion/blockchain-service';
2
2
  import { wallet, api } from './helpers/BSNeo3NeonJsSingletonHelper';
3
3
  export type TBSNeo3NetworkId = TBSNetworkId<'mainnet' | 'testnet'>;
4
- export interface IBSNeo3<N extends string = string> extends IBlockchainService<N, TBSNeo3NetworkId>, IBSWithClaim<N>, IBSWithNameService, IBSWithFee<N>, IBSWithNft, IBSWithExplorer, IBSWithLedger<N>, IBSWithNeo3NeoXBridge<N>, IBSWithEncryption<N> {
4
+ export interface IBSNeo3<N extends string = string> extends IBlockchainService<N, TBSNeo3NetworkId>, IBSWithClaim<N>, IBSWithNameService, IBSWithFee<N>, IBSWithNft, IBSWithExplorer, IBSWithLedger<N>, IBSWithNeo3NeoXBridge<N>, IBSWithEncryption<N>, IBSWithWalletConnect {
5
5
  generateSigningCallback(account: TBSAccount<N>): Promise<{
6
6
  neonJsAccount: wallet.Account;
7
7
  signingCallback: api.SigningFunction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo3",
3
- "version": "1.16.4",
3
+ "version": "1.17.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -15,7 +15,7 @@
15
15
  "@cityofzion/neon-core": "~5.7.0",
16
16
  "@cityofzion/neon-dappkit": "~0.6.0",
17
17
  "axios": "~1.12.2",
18
- "@cityofzion/blockchain-service": "1.21.3"
18
+ "@cityofzion/blockchain-service": "1.22.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@cityofzion/neon-dappkit-types": "~0.5.0",