@gnolang/gnonative 4.1.0 → 4.1.1
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/android/libs/gnocore.aar +0 -0
- package/build/api/GnoNativeApi.d.ts +4 -4
- package/build/api/GnoNativeApi.d.ts.map +1 -1
- package/build/api/GnoNativeApi.js +40 -56
- package/build/api/GnoNativeApi.js.map +1 -1
- package/build/api/vendor/gnonativetypes_pb.d.ts +564 -743
- package/build/api/vendor/gnonativetypes_pb.d.ts.map +1 -1
- package/build/api/vendor/gnonativetypes_pb.js +376 -2503
- package/build/api/vendor/gnonativetypes_pb.js.map +1 -1
- package/build/api/vendor/rpc_pb.d.ts +440 -15
- package/build/api/vendor/rpc_pb.d.ts.map +1 -1
- package/build/api/vendor/rpc_pb.js +20 -70
- package/build/api/vendor/rpc_pb.js.map +1 -1
- package/build/grpc/client.d.ts +3 -3
- package/build/grpc/client.d.ts.map +1 -1
- package/build/grpc/client.js +3 -3
- package/build/grpc/client.js.map +1 -1
- package/build/grpc/transport_native.d.ts.map +1 -1
- package/build/grpc/transport_native.js +20 -25
- package/build/grpc/transport_native.js.map +1 -1
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/A/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/Current/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64_x86_64-simulator/GnoCore.framework/GnoCore +0 -0
- package/package.json +4 -4
- package/src/api/GnoNativeApi.ts +71 -143
- package/src/api/vendor/gnonativetypes_pb.ts +757 -2204
- package/src/api/vendor/rpc_pb.ts +451 -75
- package/src/grpc/client.ts +4 -4
- package/src/grpc/transport_native.ts +35 -36
- package/build/api/vendor/rpc_connect.d.ts +0 -461
- package/build/api/vendor/rpc_connect.d.ts.map +0 -1
- package/build/api/vendor/rpc_connect.js +0 -465
- package/build/api/vendor/rpc_connect.js.map +0 -1
- package/src/api/vendor/rpc_connect.ts +0 -467
package/src/api/GnoNativeApi.ts
CHANGED
|
@@ -1,65 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Client } from '@connectrpc/connect';
|
|
2
2
|
|
|
3
3
|
import { GnoKeyApi, BridgeStatus, Config } from './types';
|
|
4
4
|
import {
|
|
5
|
-
AddressFromBech32Request,
|
|
6
|
-
AddressToBech32Request,
|
|
7
|
-
AddressFromMnemonicRequest,
|
|
8
5
|
BroadcastTxCommitResponse,
|
|
9
|
-
CallRequest,
|
|
10
6
|
CallResponse,
|
|
11
|
-
CreateAccountRequest,
|
|
12
|
-
DeleteAccountRequest,
|
|
13
7
|
DeleteAccountResponse,
|
|
14
|
-
GenerateRecoveryPhraseRequest,
|
|
15
|
-
GetActivatedAccountRequest,
|
|
16
8
|
GetActivatedAccountResponse,
|
|
17
|
-
GetChainIDRequest,
|
|
18
|
-
GetKeyInfoByAddressRequest,
|
|
19
|
-
GetKeyInfoByNameOrAddressRequest,
|
|
20
|
-
GetKeyInfoByNameRequest,
|
|
21
|
-
GetRemoteRequest,
|
|
22
|
-
HasKeyByAddressRequest,
|
|
23
|
-
HasKeyByNameOrAddressRequest,
|
|
24
|
-
HasKeyByNameRequest,
|
|
25
|
-
HelloRequest,
|
|
26
9
|
HelloStreamResponse,
|
|
27
10
|
KeyInfo,
|
|
28
|
-
ListKeyInfoRequest,
|
|
29
11
|
MakeTxResponse,
|
|
30
|
-
MsgCall,
|
|
31
12
|
Coin,
|
|
32
|
-
MsgSend,
|
|
33
|
-
QEvalRequest,
|
|
34
|
-
QueryAccountRequest,
|
|
35
13
|
QueryAccountResponse,
|
|
36
|
-
QueryRequest,
|
|
37
14
|
QueryResponse,
|
|
38
|
-
RenderRequest,
|
|
39
|
-
ActivateAccountRequest,
|
|
40
15
|
ActivateAccountResponse,
|
|
41
|
-
SendRequest,
|
|
42
16
|
SendResponse,
|
|
43
|
-
SetChainIDRequest,
|
|
44
17
|
SetChainIDResponse,
|
|
45
|
-
SetPasswordRequest,
|
|
46
18
|
SetPasswordResponse,
|
|
47
|
-
SetRemoteRequest,
|
|
48
19
|
SetRemoteResponse,
|
|
49
20
|
SignTxResponse,
|
|
50
|
-
RotatePasswordRequest,
|
|
51
21
|
RotatePasswordResponse,
|
|
52
|
-
EstimateGasRequest,
|
|
53
22
|
EstimateGasResponse,
|
|
54
23
|
} from './vendor/gnonativetypes_pb';
|
|
55
|
-
import { GnoNativeService } from './vendor/
|
|
24
|
+
import { GnoNativeService } from './vendor/rpc_pb';
|
|
56
25
|
import { GoBridge, GoBridgeInterface } from '../GoBridge';
|
|
57
26
|
import * as Grpc from '../grpc/client';
|
|
58
27
|
|
|
59
28
|
export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
60
29
|
bridgeStatus = BridgeStatus.Stopped;
|
|
61
30
|
config: Config;
|
|
62
|
-
clientInstance:
|
|
31
|
+
clientInstance: Client<typeof GnoNativeService> | undefined;
|
|
63
32
|
|
|
64
33
|
constructor(config: Config) {
|
|
65
34
|
this.config = config;
|
|
@@ -83,10 +52,8 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
83
52
|
console.log('GoBridge GRPC client instance. Done.');
|
|
84
53
|
|
|
85
54
|
try {
|
|
86
|
-
await this.clientInstance?.setRemote(
|
|
87
|
-
await this.clientInstance?.setChainID(
|
|
88
|
-
new SetChainIDRequest({ chainId: this.config.chain_id }),
|
|
89
|
-
);
|
|
55
|
+
await this.clientInstance?.setRemote({ remote: this.config.remote });
|
|
56
|
+
await this.clientInstance?.setChainID({ chainId: this.config.chain_id });
|
|
90
57
|
console.log('✅ GnoNative bridge initialized.');
|
|
91
58
|
return true;
|
|
92
59
|
} catch (error) {
|
|
@@ -115,13 +82,13 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
115
82
|
|
|
116
83
|
async setRemote(remote: string): Promise<SetRemoteResponse> {
|
|
117
84
|
const client = this.#getClient();
|
|
118
|
-
const response = client.setRemote(
|
|
85
|
+
const response = client.setRemote({ remote });
|
|
119
86
|
return response;
|
|
120
87
|
}
|
|
121
88
|
|
|
122
89
|
async getRemote(): Promise<string> {
|
|
123
90
|
const client = this.#getClient();
|
|
124
|
-
const response = await client.getRemote(
|
|
91
|
+
const response = await client.getRemote({});
|
|
125
92
|
return response.remote;
|
|
126
93
|
}
|
|
127
94
|
|
|
@@ -145,28 +112,26 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
145
112
|
sequenceNumber: bigint = BigInt(0),
|
|
146
113
|
): Promise<EstimateGasResponse> {
|
|
147
114
|
const client = this.#getClient();
|
|
148
|
-
const response = client.estimateGas(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}),
|
|
157
|
-
);
|
|
115
|
+
const response = client.estimateGas({
|
|
116
|
+
txJson,
|
|
117
|
+
address,
|
|
118
|
+
securityMargin,
|
|
119
|
+
updateTx,
|
|
120
|
+
accountNumber,
|
|
121
|
+
sequenceNumber,
|
|
122
|
+
});
|
|
158
123
|
return response;
|
|
159
124
|
}
|
|
160
125
|
|
|
161
126
|
async setChainID(chainId: string): Promise<SetChainIDResponse> {
|
|
162
127
|
const client = this.#getClient();
|
|
163
|
-
const response = client.setChainID(
|
|
128
|
+
const response = client.setChainID({ chainId });
|
|
164
129
|
return response;
|
|
165
130
|
}
|
|
166
131
|
|
|
167
132
|
async getChainID() {
|
|
168
133
|
const client = this.#getClient();
|
|
169
|
-
const response = await client.getChainID(
|
|
134
|
+
const response = await client.getChainID({});
|
|
170
135
|
return response.chainId;
|
|
171
136
|
}
|
|
172
137
|
|
|
@@ -176,65 +141,59 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
176
141
|
password: string,
|
|
177
142
|
): Promise<KeyInfo | undefined> {
|
|
178
143
|
const client = this.#getClient();
|
|
179
|
-
const reponse = await client.createAccount(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}),
|
|
185
|
-
);
|
|
144
|
+
const reponse = await client.createAccount({
|
|
145
|
+
nameOrBech32,
|
|
146
|
+
mnemonic,
|
|
147
|
+
password,
|
|
148
|
+
});
|
|
186
149
|
return reponse.key;
|
|
187
150
|
}
|
|
188
151
|
|
|
189
152
|
async generateRecoveryPhrase() {
|
|
190
153
|
const client = this.#getClient();
|
|
191
|
-
const response = await client.generateRecoveryPhrase(
|
|
154
|
+
const response = await client.generateRecoveryPhrase({});
|
|
192
155
|
return response.phrase;
|
|
193
156
|
}
|
|
194
157
|
|
|
195
158
|
async hasKeyByName(name: string) {
|
|
196
159
|
const client = this.#getClient();
|
|
197
|
-
const response = await client.hasKeyByName(
|
|
160
|
+
const response = await client.hasKeyByName({ name });
|
|
198
161
|
return response.has;
|
|
199
162
|
}
|
|
200
163
|
|
|
201
164
|
async hasKeyByAddress(address: Uint8Array) {
|
|
202
165
|
const client = this.#getClient();
|
|
203
|
-
const response = await client.hasKeyByAddress(
|
|
166
|
+
const response = await client.hasKeyByAddress({ address });
|
|
204
167
|
return response.has;
|
|
205
168
|
}
|
|
206
169
|
|
|
207
170
|
async hasKeyByNameOrAddress(nameOrBech32: string) {
|
|
208
171
|
const client = this.#getClient();
|
|
209
|
-
const response = await client.hasKeyByNameOrAddress(
|
|
210
|
-
new HasKeyByNameOrAddressRequest({ nameOrBech32 }),
|
|
211
|
-
);
|
|
172
|
+
const response = await client.hasKeyByNameOrAddress({ nameOrBech32 });
|
|
212
173
|
return response.has;
|
|
213
174
|
}
|
|
214
175
|
|
|
215
176
|
async getKeyInfoByName(name: string): Promise<KeyInfo | undefined> {
|
|
216
177
|
const client = this.#getClient();
|
|
217
|
-
const response = await client.getKeyInfoByName(
|
|
178
|
+
const response = await client.getKeyInfoByName({ name });
|
|
218
179
|
return response.key;
|
|
219
180
|
}
|
|
220
181
|
|
|
221
182
|
async getKeyInfoByAddress(address: Uint8Array): Promise<KeyInfo | undefined> {
|
|
222
183
|
const client = this.#getClient();
|
|
223
|
-
const response = await client.getKeyInfoByAddress(
|
|
184
|
+
const response = await client.getKeyInfoByAddress({ address });
|
|
224
185
|
return response.key;
|
|
225
186
|
}
|
|
226
187
|
|
|
227
188
|
async getKeyInfoByNameOrAddress(nameOrBech32: string): Promise<KeyInfo | undefined> {
|
|
228
189
|
const client = this.#getClient();
|
|
229
|
-
const response = await client.getKeyInfoByNameOrAddress(
|
|
230
|
-
new GetKeyInfoByNameOrAddressRequest({ nameOrBech32 }),
|
|
231
|
-
);
|
|
190
|
+
const response = await client.getKeyInfoByNameOrAddress({ nameOrBech32 });
|
|
232
191
|
return response.key;
|
|
233
192
|
}
|
|
234
193
|
|
|
235
194
|
async listKeyInfo(): Promise<KeyInfo[]> {
|
|
236
195
|
const client = this.#getClient();
|
|
237
|
-
const response = await client.listKeyInfo(
|
|
196
|
+
const response = await client.listKeyInfo({});
|
|
238
197
|
return response.keys;
|
|
239
198
|
}
|
|
240
199
|
|
|
@@ -292,15 +251,11 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
292
251
|
|
|
293
252
|
async activateAccount(nameOrBech32: string): Promise<ActivateAccountResponse> {
|
|
294
253
|
const client = this.#getClient();
|
|
295
|
-
const response = client.activateAccount(
|
|
296
|
-
new ActivateAccountRequest({
|
|
297
|
-
nameOrBech32,
|
|
298
|
-
}),
|
|
299
|
-
);
|
|
254
|
+
const response = client.activateAccount({ nameOrBech32 });
|
|
300
255
|
return response;
|
|
301
256
|
}
|
|
302
257
|
|
|
303
|
-
async getClient(): Promise<
|
|
258
|
+
async getClient(): Promise<Client<typeof GnoNativeService>> {
|
|
304
259
|
if (!this.clientInstance) {
|
|
305
260
|
throw new Error('GoBridge client instance not initialized.');
|
|
306
261
|
}
|
|
@@ -313,7 +268,7 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
313
268
|
|
|
314
269
|
async setPassword(password: string, address: Uint8Array): Promise<SetPasswordResponse> {
|
|
315
270
|
const client = this.#getClient();
|
|
316
|
-
const response = client.setPassword(
|
|
271
|
+
const response = client.setPassword({ password, address });
|
|
317
272
|
return response;
|
|
318
273
|
}
|
|
319
274
|
|
|
@@ -322,19 +277,19 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
322
277
|
addresses: Uint8Array[],
|
|
323
278
|
): Promise<RotatePasswordResponse> {
|
|
324
279
|
const client = this.#getClient();
|
|
325
|
-
const response = client.rotatePassword(
|
|
280
|
+
const response = client.rotatePassword({ newPassword, addresses });
|
|
326
281
|
return response;
|
|
327
282
|
}
|
|
328
283
|
|
|
329
284
|
async getActivatedAccount(): Promise<GetActivatedAccountResponse> {
|
|
330
285
|
const client = this.#getClient();
|
|
331
|
-
const response = client.getActivatedAccount(
|
|
286
|
+
const response = client.getActivatedAccount({});
|
|
332
287
|
return response;
|
|
333
288
|
}
|
|
334
289
|
|
|
335
290
|
async queryAccount(address: Uint8Array): Promise<QueryAccountResponse> {
|
|
336
291
|
const client = this.#getClient();
|
|
337
|
-
const reponse = client.queryAccount(
|
|
292
|
+
const reponse = client.queryAccount({ address });
|
|
338
293
|
return reponse;
|
|
339
294
|
}
|
|
340
295
|
|
|
@@ -344,46 +299,25 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
344
299
|
skipPassword: boolean,
|
|
345
300
|
): Promise<DeleteAccountResponse> {
|
|
346
301
|
const client = this.#getClient();
|
|
347
|
-
const response = client.deleteAccount(
|
|
348
|
-
new DeleteAccountRequest({
|
|
349
|
-
nameOrBech32,
|
|
350
|
-
password,
|
|
351
|
-
skipPassword,
|
|
352
|
-
}),
|
|
353
|
-
);
|
|
302
|
+
const response = client.deleteAccount({ nameOrBech32, password, skipPassword });
|
|
354
303
|
return response;
|
|
355
304
|
}
|
|
356
305
|
|
|
357
306
|
async query(path: string, data: Uint8Array): Promise<QueryResponse> {
|
|
358
307
|
const client = this.#getClient();
|
|
359
|
-
const reponse = client.query(
|
|
360
|
-
new QueryRequest({
|
|
361
|
-
path,
|
|
362
|
-
data,
|
|
363
|
-
}),
|
|
364
|
-
);
|
|
308
|
+
const reponse = client.query({ path, data });
|
|
365
309
|
return reponse;
|
|
366
310
|
}
|
|
367
311
|
|
|
368
312
|
async render(packagePath: string, args: string) {
|
|
369
313
|
const client = this.#getClient();
|
|
370
|
-
const reponse = await client.render(
|
|
371
|
-
new RenderRequest({
|
|
372
|
-
packagePath,
|
|
373
|
-
args,
|
|
374
|
-
}),
|
|
375
|
-
);
|
|
314
|
+
const reponse = await client.render({ packagePath, args });
|
|
376
315
|
return reponse.result;
|
|
377
316
|
}
|
|
378
317
|
|
|
379
318
|
async qEval(packagePath: string, expression: string) {
|
|
380
319
|
const client = this.#getClient();
|
|
381
|
-
const reponse = await client.qEval(
|
|
382
|
-
new QEvalRequest({
|
|
383
|
-
packagePath,
|
|
384
|
-
expression,
|
|
385
|
-
}),
|
|
386
|
-
);
|
|
320
|
+
const reponse = await client.qEval({ packagePath, expression });
|
|
387
321
|
return reponse.result;
|
|
388
322
|
}
|
|
389
323
|
|
|
@@ -398,22 +332,20 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
398
332
|
memo?: string,
|
|
399
333
|
): Promise<AsyncIterable<CallResponse>> {
|
|
400
334
|
const client = this.#getClient();
|
|
401
|
-
const reponse = client.call(
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}),
|
|
416
|
-
);
|
|
335
|
+
const reponse = client.call({
|
|
336
|
+
gasFee,
|
|
337
|
+
gasWanted,
|
|
338
|
+
memo,
|
|
339
|
+
callerAddress,
|
|
340
|
+
msgs: [
|
|
341
|
+
{
|
|
342
|
+
packagePath,
|
|
343
|
+
fnc,
|
|
344
|
+
args,
|
|
345
|
+
send,
|
|
346
|
+
},
|
|
347
|
+
],
|
|
348
|
+
});
|
|
417
349
|
return reponse;
|
|
418
350
|
}
|
|
419
351
|
|
|
@@ -426,40 +358,36 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
426
358
|
memo?: string,
|
|
427
359
|
): Promise<AsyncIterable<SendResponse>> {
|
|
428
360
|
const client = this.#getClient();
|
|
429
|
-
const reponse = client.send(
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}),
|
|
442
|
-
);
|
|
361
|
+
const reponse = client.send({
|
|
362
|
+
gasFee,
|
|
363
|
+
gasWanted,
|
|
364
|
+
memo,
|
|
365
|
+
callerAddress,
|
|
366
|
+
msgs: [
|
|
367
|
+
{
|
|
368
|
+
toAddress,
|
|
369
|
+
amount,
|
|
370
|
+
},
|
|
371
|
+
],
|
|
372
|
+
});
|
|
443
373
|
return reponse;
|
|
444
374
|
}
|
|
445
375
|
|
|
446
376
|
async addressToBech32(address: Uint8Array) {
|
|
447
377
|
const client = this.#getClient();
|
|
448
|
-
const response = await client.addressToBech32(
|
|
378
|
+
const response = await client.addressToBech32({ address });
|
|
449
379
|
return response.bech32Address;
|
|
450
380
|
}
|
|
451
381
|
|
|
452
382
|
async addressFromMnemonic(mnemonic: string) {
|
|
453
383
|
const client = this.#getClient();
|
|
454
|
-
const response = await client.addressFromMnemonic(
|
|
384
|
+
const response = await client.addressFromMnemonic({ mnemonic });
|
|
455
385
|
return response.address;
|
|
456
386
|
}
|
|
457
387
|
|
|
458
388
|
async addressFromBech32(bech32Address: string) {
|
|
459
389
|
const client = this.#getClient();
|
|
460
|
-
const response = await client.addressFromBech32(
|
|
461
|
-
new AddressFromBech32Request({ bech32Address }),
|
|
462
|
-
);
|
|
390
|
+
const response = await client.addressFromBech32({ bech32Address });
|
|
463
391
|
return response.address;
|
|
464
392
|
}
|
|
465
393
|
|
|
@@ -472,14 +400,14 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
472
400
|
// // debug
|
|
473
401
|
async hello(name: string) {
|
|
474
402
|
const client = this.#getClient();
|
|
475
|
-
const response = await client.hello(
|
|
403
|
+
const response = await client.hello({ name });
|
|
476
404
|
return response.greeting;
|
|
477
405
|
}
|
|
478
406
|
|
|
479
407
|
// // debug
|
|
480
408
|
async helloStream(name: string): Promise<AsyncIterable<HelloStreamResponse>> {
|
|
481
409
|
const client = this.#getClient();
|
|
482
|
-
return client.helloStream(
|
|
410
|
+
return client.helloStream({ name });
|
|
483
411
|
}
|
|
484
412
|
|
|
485
413
|
// Go Bridge Interface:
|