@gnolang/gnonative 2.0.0 → 3.0.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/android/libs/gnocore.aar +0 -0
- package/build/api/GnoNativeApi.d.ts +6 -3
- package/build/api/GnoNativeApi.d.ts.map +1 -1
- package/build/api/GnoNativeApi.js +72 -44
- package/build/api/GnoNativeApi.js.map +1 -1
- package/build/api/types.d.ts +6 -3
- package/build/api/types.d.ts.map +1 -1
- package/build/api/types.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 +1 -1
- package/src/api/GnoNativeApi.ts +98 -47
- package/src/api/types.ts +22 -2
package/android/libs/gnocore.aar
CHANGED
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CallResponse, DeleteAccountResponse, GetActiveAccountResponse, GetActivatedAccountResponse, HelloStreamResponse, KeyInfo, QueryAccountResponse, QueryResponse, SelectAccountResponse, ActivateAccountResponse, SendResponse, SetChainIDResponse, SetPasswordResponse, SetRemoteResponse, UpdatePasswordResponse } from '@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb';
|
|
1
|
+
import { BroadcastTxCommitResponse, CallResponse, DeleteAccountResponse, GetActiveAccountResponse, GetActivatedAccountResponse, HelloStreamResponse, KeyInfo, MakeTxResponse, QueryAccountResponse, QueryResponse, SelectAccountResponse, ActivateAccountResponse, SendResponse, SetChainIDResponse, SetPasswordResponse, SetRemoteResponse, SignTxResponse, UpdatePasswordResponse } from '@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb';
|
|
2
2
|
import { GnoNativeService } from '@buf/gnolang_gnonative.connectrpc_es/rpc_connect';
|
|
3
3
|
import { PromiseClient } from '@connectrpc/connect';
|
|
4
4
|
import { GnoKeyApi, BridgeStatus, Config } from './types';
|
|
@@ -12,6 +12,7 @@ export declare class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
12
12
|
initClient(): Promise<boolean>;
|
|
13
13
|
setRemote(remote: string): Promise<SetRemoteResponse>;
|
|
14
14
|
getRemote(): Promise<string>;
|
|
15
|
+
signTx(txJson: string, address: Uint8Array, accountNumber?: bigint, sequenceNumber?: bigint): Promise<SignTxResponse>;
|
|
15
16
|
setChainID(chainId: string): Promise<SetChainIDResponse>;
|
|
16
17
|
getChainID(): Promise<string>;
|
|
17
18
|
createAccount(nameOrBech32: string, mnemonic: string, password: string): Promise<KeyInfo | undefined>;
|
|
@@ -23,6 +24,7 @@ export declare class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
23
24
|
getKeyInfoByAddress(address: Uint8Array): Promise<KeyInfo | undefined>;
|
|
24
25
|
getKeyInfoByNameOrAddress(nameOrBech32: string): Promise<KeyInfo | undefined>;
|
|
25
26
|
listKeyInfo(): Promise<KeyInfo[]>;
|
|
27
|
+
makeCallTx(packagePath: string, fnc: string, args: string[], gasFee: string, gasWanted: bigint, callerAddress?: Uint8Array, send?: string, memo?: string): Promise<MakeTxResponse>;
|
|
26
28
|
selectAccount(nameOrBech32: string): Promise<SelectAccountResponse>;
|
|
27
29
|
activateAccount(nameOrBech32: string): Promise<ActivateAccountResponse>;
|
|
28
30
|
getClient(): Promise<PromiseClient<typeof GnoNativeService>>;
|
|
@@ -36,11 +38,12 @@ export declare class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
36
38
|
query(path: string, data: Uint8Array): Promise<QueryResponse>;
|
|
37
39
|
render(packagePath: string, args: string): Promise<string>;
|
|
38
40
|
qEval(packagePath: string, expression: string): Promise<string>;
|
|
39
|
-
call(packagePath: string, fnc: string, args: string[], gasFee: string, gasWanted:
|
|
40
|
-
send(toAddress: Uint8Array, send: string, gasFee: string, gasWanted:
|
|
41
|
+
call(packagePath: string, fnc: string, args: string[], gasFee: string, gasWanted: bigint, callerAddress?: Uint8Array, send?: string, memo?: string): Promise<AsyncIterable<CallResponse>>;
|
|
42
|
+
send(toAddress: Uint8Array, send: string, gasFee: string, gasWanted: bigint, callerAddress?: Uint8Array, memo?: string): Promise<AsyncIterable<SendResponse>>;
|
|
41
43
|
addressToBech32(address: Uint8Array): Promise<string>;
|
|
42
44
|
addressFromMnemonic(mnemonic: string): Promise<Uint8Array>;
|
|
43
45
|
addressFromBech32(bech32Address: string): Promise<Uint8Array>;
|
|
46
|
+
broadcastTxCommit(signedTxJson: string): Promise<AsyncIterable<BroadcastTxCommitResponse>>;
|
|
44
47
|
hello(name: string): Promise<string>;
|
|
45
48
|
helloStream(name: string): Promise<AsyncIterable<HelloStreamResponse>>;
|
|
46
49
|
initBridge(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GnoNativeApi.d.ts","sourceRoot":"","sources":["../../src/api/GnoNativeApi.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"GnoNativeApi.d.ts","sourceRoot":"","sources":["../../src/api/GnoNativeApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,yBAAyB,EAEzB,YAAY,EAGZ,qBAAqB,EAGrB,wBAAwB,EAExB,2BAA2B,EAU3B,mBAAmB,EACnB,OAAO,EAEP,cAAc,EAKd,oBAAoB,EAEpB,aAAa,EAGb,qBAAqB,EAErB,uBAAuB,EAEvB,YAAY,EAEZ,kBAAkB,EAElB,mBAAmB,EAEnB,iBAAiB,EACjB,cAAc,EAEd,sBAAsB,EACvB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;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iB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG7C"}
|
|
@@ -54,27 +54,32 @@ export class GnoNativeApi {
|
|
|
54
54
|
return this.clientInstance;
|
|
55
55
|
}
|
|
56
56
|
async setRemote(remote) {
|
|
57
|
-
const client =
|
|
58
|
-
const response =
|
|
57
|
+
const client = this.#getClient();
|
|
58
|
+
const response = client.setRemote(new SetRemoteRequest({ remote }));
|
|
59
59
|
return response;
|
|
60
60
|
}
|
|
61
61
|
async getRemote() {
|
|
62
|
-
const client =
|
|
62
|
+
const client = this.#getClient();
|
|
63
63
|
const response = await client.getRemote(new GetRemoteRequest());
|
|
64
64
|
return response.remote;
|
|
65
65
|
}
|
|
66
|
+
async signTx(txJson, address, accountNumber = BigInt(0), sequenceNumber = BigInt(0)) {
|
|
67
|
+
const client = this.#getClient();
|
|
68
|
+
const response = client.signTx({ txJson, address, accountNumber, sequenceNumber });
|
|
69
|
+
return response;
|
|
70
|
+
}
|
|
66
71
|
async setChainID(chainId) {
|
|
67
|
-
const client =
|
|
68
|
-
const response =
|
|
72
|
+
const client = this.#getClient();
|
|
73
|
+
const response = client.setChainID(new SetChainIDRequest({ chainId }));
|
|
69
74
|
return response;
|
|
70
75
|
}
|
|
71
76
|
async getChainID() {
|
|
72
|
-
const client =
|
|
77
|
+
const client = this.#getClient();
|
|
73
78
|
const response = await client.getChainID(new GetChainIDRequest());
|
|
74
79
|
return response.chainId;
|
|
75
80
|
}
|
|
76
81
|
async createAccount(nameOrBech32, mnemonic, password) {
|
|
77
|
-
const client =
|
|
82
|
+
const client = this.#getClient();
|
|
78
83
|
const reponse = await client.createAccount(new CreateAccountRequest({
|
|
79
84
|
nameOrBech32,
|
|
80
85
|
mnemonic,
|
|
@@ -83,55 +88,73 @@ export class GnoNativeApi {
|
|
|
83
88
|
return reponse.key;
|
|
84
89
|
}
|
|
85
90
|
async generateRecoveryPhrase() {
|
|
86
|
-
const client =
|
|
91
|
+
const client = this.#getClient();
|
|
87
92
|
const response = await client.generateRecoveryPhrase(new GenerateRecoveryPhraseRequest());
|
|
88
93
|
return response.phrase;
|
|
89
94
|
}
|
|
90
95
|
async hasKeyByName(name) {
|
|
91
|
-
const client =
|
|
96
|
+
const client = this.#getClient();
|
|
92
97
|
const response = await client.hasKeyByName(new HasKeyByNameRequest({ name }));
|
|
93
98
|
return response.has;
|
|
94
99
|
}
|
|
95
100
|
async hasKeyByAddress(address) {
|
|
96
|
-
const client =
|
|
101
|
+
const client = this.#getClient();
|
|
97
102
|
const response = await client.hasKeyByAddress(new HasKeyByAddressRequest({ address }));
|
|
98
103
|
return response.has;
|
|
99
104
|
}
|
|
100
105
|
async hasKeyByNameOrAddress(nameOrBech32) {
|
|
101
|
-
const client =
|
|
106
|
+
const client = this.#getClient();
|
|
102
107
|
const response = await client.hasKeyByNameOrAddress(new HasKeyByNameOrAddressRequest({ nameOrBech32 }));
|
|
103
108
|
return response.has;
|
|
104
109
|
}
|
|
105
110
|
async getKeyInfoByName(name) {
|
|
106
|
-
const client =
|
|
111
|
+
const client = this.#getClient();
|
|
107
112
|
const response = await client.getKeyInfoByName(new GetKeyInfoByNameRequest({ name }));
|
|
108
113
|
return response.key;
|
|
109
114
|
}
|
|
110
115
|
async getKeyInfoByAddress(address) {
|
|
111
|
-
const client =
|
|
116
|
+
const client = this.#getClient();
|
|
112
117
|
const response = await client.getKeyInfoByAddress(new GetKeyInfoByAddressRequest({ address }));
|
|
113
118
|
return response.key;
|
|
114
119
|
}
|
|
115
120
|
async getKeyInfoByNameOrAddress(nameOrBech32) {
|
|
116
|
-
const client =
|
|
121
|
+
const client = this.#getClient();
|
|
117
122
|
const response = await client.getKeyInfoByNameOrAddress(new GetKeyInfoByNameOrAddressRequest({ nameOrBech32 }));
|
|
118
123
|
return response.key;
|
|
119
124
|
}
|
|
120
125
|
async listKeyInfo() {
|
|
121
|
-
const client =
|
|
126
|
+
const client = this.#getClient();
|
|
122
127
|
const response = await client.listKeyInfo(new ListKeyInfoRequest());
|
|
123
128
|
return response.keys;
|
|
124
129
|
}
|
|
130
|
+
async makeCallTx(packagePath, fnc, args, gasFee, gasWanted, callerAddress, send, memo) {
|
|
131
|
+
const client = this.#getClient();
|
|
132
|
+
const reponse = client.makeCallTx({
|
|
133
|
+
gasFee,
|
|
134
|
+
gasWanted,
|
|
135
|
+
memo,
|
|
136
|
+
callerAddress,
|
|
137
|
+
msgs: [
|
|
138
|
+
{
|
|
139
|
+
packagePath,
|
|
140
|
+
fnc,
|
|
141
|
+
args,
|
|
142
|
+
send,
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
return reponse;
|
|
147
|
+
}
|
|
125
148
|
async selectAccount(nameOrBech32) {
|
|
126
|
-
const client =
|
|
127
|
-
const response =
|
|
149
|
+
const client = this.#getClient();
|
|
150
|
+
const response = client.selectAccount(new SelectAccountRequest({
|
|
128
151
|
nameOrBech32,
|
|
129
152
|
}));
|
|
130
153
|
return response;
|
|
131
154
|
}
|
|
132
155
|
async activateAccount(nameOrBech32) {
|
|
133
|
-
const client =
|
|
134
|
-
const response =
|
|
156
|
+
const client = this.#getClient();
|
|
157
|
+
const response = client.activateAccount(new ActivateAccountRequest({
|
|
135
158
|
nameOrBech32,
|
|
136
159
|
}));
|
|
137
160
|
return response;
|
|
@@ -146,33 +169,33 @@ export class GnoNativeApi {
|
|
|
146
169
|
return this.clientInstance !== undefined;
|
|
147
170
|
}
|
|
148
171
|
async setPassword(password, address) {
|
|
149
|
-
const client =
|
|
150
|
-
const response =
|
|
172
|
+
const client = this.#getClient();
|
|
173
|
+
const response = client.setPassword(new SetPasswordRequest({ password, address }));
|
|
151
174
|
return response;
|
|
152
175
|
}
|
|
153
176
|
async updatePassword(newPassword, addresses) {
|
|
154
|
-
const client =
|
|
155
|
-
const response =
|
|
177
|
+
const client = this.#getClient();
|
|
178
|
+
const response = client.updatePassword(new UpdatePasswordRequest({ newPassword, addresses }));
|
|
156
179
|
return response;
|
|
157
180
|
}
|
|
158
181
|
async getActiveAccount() {
|
|
159
|
-
const client =
|
|
160
|
-
const response =
|
|
182
|
+
const client = this.#getClient();
|
|
183
|
+
const response = client.getActiveAccount(new GetActiveAccountRequest());
|
|
161
184
|
return response;
|
|
162
185
|
}
|
|
163
186
|
async getActivatedAccount() {
|
|
164
|
-
const client =
|
|
165
|
-
const response =
|
|
187
|
+
const client = this.#getClient();
|
|
188
|
+
const response = client.getActivatedAccount(new GetActivatedAccountRequest());
|
|
166
189
|
return response;
|
|
167
190
|
}
|
|
168
191
|
async queryAccount(address) {
|
|
169
|
-
const client =
|
|
170
|
-
const reponse =
|
|
192
|
+
const client = this.#getClient();
|
|
193
|
+
const reponse = client.queryAccount(new QueryAccountRequest({ address }));
|
|
171
194
|
return reponse;
|
|
172
195
|
}
|
|
173
196
|
async deleteAccount(nameOrBech32, password, skipPassword) {
|
|
174
|
-
const client =
|
|
175
|
-
const response =
|
|
197
|
+
const client = this.#getClient();
|
|
198
|
+
const response = client.deleteAccount(new DeleteAccountRequest({
|
|
176
199
|
nameOrBech32,
|
|
177
200
|
password,
|
|
178
201
|
skipPassword,
|
|
@@ -180,15 +203,15 @@ export class GnoNativeApi {
|
|
|
180
203
|
return response;
|
|
181
204
|
}
|
|
182
205
|
async query(path, data) {
|
|
183
|
-
const client =
|
|
184
|
-
const reponse =
|
|
206
|
+
const client = this.#getClient();
|
|
207
|
+
const reponse = client.query(new QueryRequest({
|
|
185
208
|
path,
|
|
186
209
|
data,
|
|
187
210
|
}));
|
|
188
211
|
return reponse;
|
|
189
212
|
}
|
|
190
213
|
async render(packagePath, args) {
|
|
191
|
-
const client =
|
|
214
|
+
const client = this.#getClient();
|
|
192
215
|
const reponse = await client.render(new RenderRequest({
|
|
193
216
|
packagePath,
|
|
194
217
|
args,
|
|
@@ -196,7 +219,7 @@ export class GnoNativeApi {
|
|
|
196
219
|
return reponse.result;
|
|
197
220
|
}
|
|
198
221
|
async qEval(packagePath, expression) {
|
|
199
|
-
const client =
|
|
222
|
+
const client = this.#getClient();
|
|
200
223
|
const reponse = await client.qEval(new QEvalRequest({
|
|
201
224
|
packagePath,
|
|
202
225
|
expression,
|
|
@@ -204,10 +227,10 @@ export class GnoNativeApi {
|
|
|
204
227
|
return reponse.result;
|
|
205
228
|
}
|
|
206
229
|
async call(packagePath, fnc, args, gasFee, gasWanted, callerAddress, send, memo) {
|
|
207
|
-
const client =
|
|
230
|
+
const client = this.#getClient();
|
|
208
231
|
const reponse = client.call(new CallRequest({
|
|
209
232
|
gasFee,
|
|
210
|
-
gasWanted
|
|
233
|
+
gasWanted,
|
|
211
234
|
memo,
|
|
212
235
|
callerAddress,
|
|
213
236
|
msgs: [
|
|
@@ -222,10 +245,10 @@ export class GnoNativeApi {
|
|
|
222
245
|
return reponse;
|
|
223
246
|
}
|
|
224
247
|
async send(toAddress, send, gasFee, gasWanted, callerAddress, memo) {
|
|
225
|
-
const client =
|
|
248
|
+
const client = this.#getClient();
|
|
226
249
|
const reponse = client.send(new SendRequest({
|
|
227
250
|
gasFee,
|
|
228
|
-
gasWanted
|
|
251
|
+
gasWanted,
|
|
229
252
|
memo,
|
|
230
253
|
callerAddress,
|
|
231
254
|
msgs: [
|
|
@@ -238,29 +261,34 @@ export class GnoNativeApi {
|
|
|
238
261
|
return reponse;
|
|
239
262
|
}
|
|
240
263
|
async addressToBech32(address) {
|
|
241
|
-
const client =
|
|
264
|
+
const client = this.#getClient();
|
|
242
265
|
const response = await client.addressToBech32(new AddressToBech32Request({ address }));
|
|
243
266
|
return response.bech32Address;
|
|
244
267
|
}
|
|
245
268
|
async addressFromMnemonic(mnemonic) {
|
|
246
|
-
const client =
|
|
269
|
+
const client = this.#getClient();
|
|
247
270
|
const response = await client.addressFromMnemonic(new AddressFromMnemonicRequest({ mnemonic }));
|
|
248
271
|
return response.address;
|
|
249
272
|
}
|
|
250
273
|
async addressFromBech32(bech32Address) {
|
|
251
|
-
const client =
|
|
274
|
+
const client = this.#getClient();
|
|
252
275
|
const response = await client.addressFromBech32(new AddressFromBech32Request({ bech32Address }));
|
|
253
276
|
return response.address;
|
|
254
277
|
}
|
|
278
|
+
async broadcastTxCommit(signedTxJson) {
|
|
279
|
+
const client = this.#getClient();
|
|
280
|
+
const response = client.broadcastTxCommit({ signedTxJson });
|
|
281
|
+
return response;
|
|
282
|
+
}
|
|
255
283
|
// // debug
|
|
256
284
|
async hello(name) {
|
|
257
|
-
const client =
|
|
285
|
+
const client = this.#getClient();
|
|
258
286
|
const response = await client.hello(new HelloRequest({ name }));
|
|
259
287
|
return response.greeting;
|
|
260
288
|
}
|
|
261
289
|
// // debug
|
|
262
290
|
async helloStream(name) {
|
|
263
|
-
const client =
|
|
291
|
+
const client = this.#getClient();
|
|
264
292
|
return client.helloStream(new HelloRequest({ name }));
|
|
265
293
|
}
|
|
266
294
|
// Go Bridge Interface:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GnoNativeApi.js","sourceRoot":"","sources":["../../src/api/GnoNativeApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAC1B,WAAW,EAEX,oBAAoB,EACpB,oBAAoB,EAEpB,6BAA6B,EAC7B,uBAAuB,EAEvB,0BAA0B,EAE1B,iBAAiB,EACjB,0BAA0B,EAC1B,gCAAgC,EAChC,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,EAC5B,mBAAmB,EACnB,YAAY,EAGZ,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,YAAY,EACZ,mBAAmB,EAEnB,YAAY,EAEZ,aAAa,EACb,oBAAoB,EAEpB,sBAAsB,EAEtB,WAAW,EAEX,iBAAiB,EAEjB,kBAAkB,EAElB,gBAAgB,EAEhB,qBAAqB,GAEtB,MAAM,sDAAsD,CAAC;AAI9D,OAAO,EAAa,YAAY,EAAU,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAC1D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AO,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,iBAAiB,CAAC,EAAU;QAC1B,OAAO,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import {\n AddressFromBech32Request,\n AddressToBech32Request,\n AddressFromMnemonicRequest,\n CallRequest,\n CallResponse,\n CreateAccountRequest,\n DeleteAccountRequest,\n DeleteAccountResponse,\n GenerateRecoveryPhraseRequest,\n GetActiveAccountRequest,\n GetActiveAccountResponse,\n GetActivatedAccountRequest,\n GetActivatedAccountResponse,\n GetChainIDRequest,\n GetKeyInfoByAddressRequest,\n GetKeyInfoByNameOrAddressRequest,\n GetKeyInfoByNameRequest,\n GetRemoteRequest,\n HasKeyByAddressRequest,\n HasKeyByNameOrAddressRequest,\n HasKeyByNameRequest,\n HelloRequest,\n HelloStreamResponse,\n KeyInfo,\n ListKeyInfoRequest,\n MsgCall,\n MsgSend,\n QEvalRequest,\n QueryAccountRequest,\n QueryAccountResponse,\n QueryRequest,\n QueryResponse,\n RenderRequest,\n SelectAccountRequest,\n SelectAccountResponse,\n ActivateAccountRequest,\n ActivateAccountResponse,\n SendRequest,\n SendResponse,\n SetChainIDRequest,\n SetChainIDResponse,\n SetPasswordRequest,\n SetPasswordResponse,\n SetRemoteRequest,\n SetRemoteResponse,\n UpdatePasswordRequest,\n UpdatePasswordResponse,\n} from '@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb';\nimport { GnoNativeService } from '@buf/gnolang_gnonative.connectrpc_es/rpc_connect';\nimport { PromiseClient } from '@connectrpc/connect';\n\nimport { GnoKeyApi, BridgeStatus, Config } from './types';\nimport { GoBridge, GoBridgeInterface } from '../GoBridge';\nimport * as Grpc from '../grpc/client';\n\nexport class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {\n bridgeStatus = BridgeStatus.Stopped;\n config: Config;\n clientInstance: PromiseClient<typeof GnoNativeService> | undefined;\n\n constructor(config: Config) {\n this.config = config;\n }\n\n async initClient() {\n if (this.bridgeStatus === BridgeStatus.Stopped) {\n console.log('Bridge stopped. Initializing...');\n await this.#initBridge();\n }\n\n if (this.clientInstance) {\n console.error('GoBridge already initialized.');\n return true;\n }\n\n const port = await GoBridge.getTcpPort();\n console.log('GoBridge GRPC client instance port: %s', port);\n const client = Grpc.createClient(port);\n this.clientInstance = client;\n console.log('GoBridge GRPC client instance. Done.');\n\n try {\n await this.clientInstance.setRemote(new SetRemoteRequest({ remote: this.config.remote }));\n await this.clientInstance.setChainID(\n new SetChainIDRequest({ chainId: this.config.chain_id }),\n );\n console.log('✅ GnoNative bridge initialized.');\n if (this.config.start_gnokey_mobile_service) {\n await this.startGnokeyMobileService();\n console.log('✅ Gnokey Mobile service started.');\n }\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n }\n\n async #initBridge() {\n if (this.bridgeStatus === BridgeStatus.Stopped) {\n console.log('Initializing bridge...');\n this.bridgeStatus = BridgeStatus.Starting;\n await GoBridge.initBridge();\n console.log('Bridge initialized.');\n this.bridgeStatus = BridgeStatus.Started;\n }\n }\n\n #getClient() {\n if (!this.clientInstance) {\n throw new Error('GoBridge client instance not initialized.');\n }\n\n return this.clientInstance;\n }\n\n async setRemote(remote: string): Promise<SetRemoteResponse> {\n const client = await this.#getClient();\n const response = await client.setRemote(new SetRemoteRequest({ remote }));\n return response;\n }\n\n async getRemote(): Promise<string> {\n const client = await this.#getClient();\n const response = await client.getRemote(new GetRemoteRequest());\n return response.remote;\n }\n\n async setChainID(chainId: string): Promise<SetChainIDResponse> {\n const client = await this.#getClient();\n const response = await client.setChainID(new SetChainIDRequest({ chainId }));\n return response;\n }\n\n async getChainID() {\n const client = await this.#getClient();\n const response = await client.getChainID(new GetChainIDRequest());\n return response.chainId;\n }\n\n async createAccount(\n nameOrBech32: string,\n mnemonic: string,\n password: string,\n ): Promise<KeyInfo | undefined> {\n const client = await this.#getClient();\n const reponse = await client.createAccount(\n new CreateAccountRequest({\n nameOrBech32,\n mnemonic,\n password,\n }),\n );\n return reponse.key;\n }\n\n async generateRecoveryPhrase() {\n const client = await this.#getClient();\n const response = await client.generateRecoveryPhrase(new GenerateRecoveryPhraseRequest());\n return response.phrase;\n }\n\n async hasKeyByName(name: string) {\n const client = await this.#getClient();\n const response = await client.hasKeyByName(new HasKeyByNameRequest({ name }));\n return response.has;\n }\n\n async hasKeyByAddress(address: Uint8Array) {\n const client = await this.#getClient();\n const response = await client.hasKeyByAddress(new HasKeyByAddressRequest({ address }));\n return response.has;\n }\n\n async hasKeyByNameOrAddress(nameOrBech32: string) {\n const client = await this.#getClient();\n const response = await client.hasKeyByNameOrAddress(\n new HasKeyByNameOrAddressRequest({ nameOrBech32 }),\n );\n return response.has;\n }\n\n async getKeyInfoByName(name: string): Promise<KeyInfo | undefined> {\n const client = await this.#getClient();\n const response = await client.getKeyInfoByName(new GetKeyInfoByNameRequest({ name }));\n return response.key;\n }\n\n async getKeyInfoByAddress(address: Uint8Array): Promise<KeyInfo | undefined> {\n const client = await this.#getClient();\n const response = await client.getKeyInfoByAddress(new GetKeyInfoByAddressRequest({ address }));\n return response.key;\n }\n\n async getKeyInfoByNameOrAddress(nameOrBech32: string): Promise<KeyInfo | undefined> {\n const client = await this.#getClient();\n const response = await client.getKeyInfoByNameOrAddress(\n new GetKeyInfoByNameOrAddressRequest({ nameOrBech32 }),\n );\n return response.key;\n }\n\n async listKeyInfo(): Promise<KeyInfo[]> {\n const client = await this.#getClient();\n const response = await client.listKeyInfo(new ListKeyInfoRequest());\n return response.keys;\n }\n\n async selectAccount(nameOrBech32: string): Promise<SelectAccountResponse> {\n const client = await this.#getClient();\n const response = await client.selectAccount(\n new SelectAccountRequest({\n nameOrBech32,\n }),\n );\n return response;\n }\n\n async activateAccount(nameOrBech32: string): Promise<ActivateAccountResponse> {\n const client = await this.#getClient();\n const response = await client.activateAccount(\n new ActivateAccountRequest({\n nameOrBech32,\n }),\n );\n return response;\n }\n\n async getClient(): Promise<PromiseClient<typeof GnoNativeService>> {\n if (!this.clientInstance) {\n throw new Error('GoBridge client instance not initialized.');\n }\n return this.clientInstance;\n }\n\n isInitialized(): boolean {\n return this.clientInstance !== undefined;\n }\n\n async setPassword(password: string, address?: Uint8Array): Promise<SetPasswordResponse> {\n const client = await this.#getClient();\n const response = await client.setPassword(new SetPasswordRequest({ password, address }));\n return response;\n }\n\n async updatePassword(newPassword: string, addresses: Uint8Array[]): Promise<UpdatePasswordResponse> {\n const client = await this.#getClient();\n const response = await client.updatePassword(new UpdatePasswordRequest({ newPassword, addresses }));\n return response;\n }\n\n async getActiveAccount(): Promise<GetActiveAccountResponse> {\n const client = await this.#getClient();\n const response = await client.getActiveAccount(new GetActiveAccountRequest());\n return response;\n }\n\n async getActivatedAccount(): Promise<GetActivatedAccountResponse> {\n const client = await this.#getClient();\n const response = await client.getActivatedAccount(new GetActivatedAccountRequest());\n return response;\n }\n\n async queryAccount(address: Uint8Array): Promise<QueryAccountResponse> {\n const client = await this.#getClient();\n const reponse = await client.queryAccount(new QueryAccountRequest({ address }));\n return reponse;\n }\n\n async deleteAccount(\n nameOrBech32: string,\n password: string | undefined,\n skipPassword: boolean,\n ): Promise<DeleteAccountResponse> {\n const client = await this.#getClient();\n const response = await client.deleteAccount(\n new DeleteAccountRequest({\n nameOrBech32,\n password,\n skipPassword,\n }),\n );\n return response;\n }\n\n async query(path: string, data: Uint8Array): Promise<QueryResponse> {\n const client = await this.#getClient();\n const reponse = await client.query(\n new QueryRequest({\n path,\n data,\n }),\n );\n return reponse;\n }\n\n async render(packagePath: string, args: string) {\n const client = await this.#getClient();\n const reponse = await client.render(\n new RenderRequest({\n packagePath,\n args,\n }),\n );\n return reponse.result;\n }\n\n async qEval(packagePath: string, expression: string) {\n const client = await this.#getClient();\n const reponse = await client.qEval(\n new QEvalRequest({\n packagePath,\n expression,\n }),\n );\n return reponse.result;\n }\n\n async call(\n packagePath: string,\n fnc: string,\n args: string[],\n gasFee: string,\n gasWanted: number,\n callerAddress?: Uint8Array,\n send?: string,\n memo?: string,\n ): Promise<AsyncIterable<CallResponse>> {\n const client = await this.#getClient();\n const reponse = client.call(\n new CallRequest({\n gasFee,\n gasWanted: BigInt(gasWanted),\n memo,\n callerAddress,\n msgs: [\n new MsgCall({\n packagePath,\n fnc,\n args,\n send,\n }),\n ],\n }),\n );\n return reponse;\n }\n\n async send(\n toAddress: Uint8Array,\n send: string,\n gasFee: string,\n gasWanted: number,\n callerAddress?: Uint8Array,\n memo?: string,\n ): Promise<AsyncIterable<SendResponse>> {\n const client = await this.#getClient();\n const reponse = client.send(\n new SendRequest({\n gasFee,\n gasWanted: BigInt(gasWanted),\n memo,\n callerAddress,\n msgs: [\n new MsgSend({\n toAddress,\n send,\n }),\n ],\n }),\n );\n return reponse;\n }\n\n async addressToBech32(address: Uint8Array) {\n const client = await this.#getClient();\n const response = await client.addressToBech32(new AddressToBech32Request({ address }));\n return response.bech32Address;\n }\n\n async addressFromMnemonic(mnemonic: string) {\n const client = await this.#getClient();\n const response = await client.addressFromMnemonic(new AddressFromMnemonicRequest({ mnemonic }));\n return response.address;\n }\n\n async addressFromBech32(bech32Address: string) {\n const client = await this.#getClient();\n const response = await client.addressFromBech32(\n new AddressFromBech32Request({ bech32Address }),\n );\n return response.address;\n }\n\n // // debug\n async hello(name: string) {\n const client = await this.#getClient();\n const response = await client.hello(new HelloRequest({ name }));\n return response.greeting;\n }\n\n // // debug\n async helloStream(name: string): Promise<AsyncIterable<HelloStreamResponse>> {\n const client = await this.#getClient();\n return client.helloStream(new HelloRequest({ name }));\n }\n\n // Go Bridge Interface:\n initBridge(): Promise<void> {\n return GoBridge.initBridge();\n }\n closeBridge(): Promise<void> {\n return GoBridge.closeBridge();\n }\n getTcpPort(): Promise<number> {\n return GoBridge.getTcpPort();\n }\n startGnokeyMobileService(): Promise<void> {\n return GoBridge.startGnokeyMobileService();\n }\n invokeGrpcMethod(method: string, jsonMessage: string): Promise<string> {\n return GoBridge.invokeGrpcMethod(method, jsonMessage);\n }\n createStreamClient(method: string, jsonMessage: string): Promise<string> {\n return GoBridge.createStreamClient(method, jsonMessage);\n }\n streamClientReceive(id: string): Promise<string> {\n return GoBridge.streamClientReceive(id);\n }\n closeStreamClient(id: string): Promise<void> {\n return GoBridge.closeStreamClient(id);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GnoNativeApi.js","sourceRoot":"","sources":["../../src/api/GnoNativeApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAE1B,WAAW,EAEX,oBAAoB,EACpB,oBAAoB,EAEpB,6BAA6B,EAC7B,uBAAuB,EAEvB,0BAA0B,EAE1B,iBAAiB,EACjB,0BAA0B,EAC1B,gCAAgC,EAChC,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,EAC5B,mBAAmB,EACnB,YAAY,EAGZ,kBAAkB,EAElB,OAAO,EACP,OAAO,EACP,YAAY,EACZ,mBAAmB,EAEnB,YAAY,EAEZ,aAAa,EACb,oBAAoB,EAEpB,sBAAsB,EAEtB,WAAW,EAEX,iBAAiB,EAEjB,kBAAkB,EAElB,gBAAgB,EAGhB,qBAAqB,GAEtB,MAAM,sDAAsD,CAAC;AAI9D,OAAO,EAAa,YAAY,EAAU,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,MAAM,OAAO,YAAY;IACvB,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC;IACpC,MAAM,CAAS;IACf,cAAc,CAAqD;IAEnE,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO,EAAE,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,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;IACD,gBAAgB,CAAC,MAAc,EAAE,WAAmB;QAClD,OAAO,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACxD,CAAC;IACD,kBAAkB,CAAC,MAAc,EAAE,WAAmB;QACpD,OAAO,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC;IACD,mBAAmB,CAAC,EAAU;QAC5B,OAAO,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,iBAAiB,CAAC,EAAU;QAC1B,OAAO,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import {\n AddressFromBech32Request,\n AddressToBech32Request,\n AddressFromMnemonicRequest,\n BroadcastTxCommitResponse,\n CallRequest,\n CallResponse,\n CreateAccountRequest,\n DeleteAccountRequest,\n DeleteAccountResponse,\n GenerateRecoveryPhraseRequest,\n GetActiveAccountRequest,\n GetActiveAccountResponse,\n GetActivatedAccountRequest,\n GetActivatedAccountResponse,\n GetChainIDRequest,\n GetKeyInfoByAddressRequest,\n GetKeyInfoByNameOrAddressRequest,\n GetKeyInfoByNameRequest,\n GetRemoteRequest,\n HasKeyByAddressRequest,\n HasKeyByNameOrAddressRequest,\n HasKeyByNameRequest,\n HelloRequest,\n HelloStreamResponse,\n KeyInfo,\n ListKeyInfoRequest,\n MakeTxResponse,\n MsgCall,\n MsgSend,\n QEvalRequest,\n QueryAccountRequest,\n QueryAccountResponse,\n QueryRequest,\n QueryResponse,\n RenderRequest,\n SelectAccountRequest,\n SelectAccountResponse,\n ActivateAccountRequest,\n ActivateAccountResponse,\n SendRequest,\n SendResponse,\n SetChainIDRequest,\n SetChainIDResponse,\n SetPasswordRequest,\n SetPasswordResponse,\n SetRemoteRequest,\n SetRemoteResponse,\n SignTxResponse,\n UpdatePasswordRequest,\n UpdatePasswordResponse,\n} from '@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb';\nimport { GnoNativeService } from '@buf/gnolang_gnonative.connectrpc_es/rpc_connect';\nimport { PromiseClient } from '@connectrpc/connect';\n\nimport { GnoKeyApi, BridgeStatus, Config } from './types';\nimport { GoBridge, GoBridgeInterface } from '../GoBridge';\nimport * as Grpc from '../grpc/client';\n\nexport class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {\n bridgeStatus = BridgeStatus.Stopped;\n config: Config;\n clientInstance: PromiseClient<typeof GnoNativeService> | undefined;\n\n constructor(config: Config) {\n this.config = config;\n }\n\n async initClient() {\n if (this.bridgeStatus === BridgeStatus.Stopped) {\n console.log('Bridge stopped. Initializing...');\n await this.#initBridge();\n }\n\n if (this.clientInstance) {\n console.error('GoBridge already initialized.');\n return true;\n }\n\n const port = await GoBridge.getTcpPort();\n console.log('GoBridge GRPC client instance port: %s', port);\n const client = Grpc.createClient(port);\n this.clientInstance = client;\n console.log('GoBridge GRPC client instance. Done.');\n\n try {\n await this.clientInstance.setRemote(new SetRemoteRequest({ remote: this.config.remote }));\n await this.clientInstance.setChainID(\n new SetChainIDRequest({ chainId: this.config.chain_id }),\n );\n console.log('✅ GnoNative bridge initialized.');\n if (this.config.start_gnokey_mobile_service) {\n await this.startGnokeyMobileService();\n console.log('✅ Gnokey Mobile service started.');\n }\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n }\n\n async #initBridge() {\n if (this.bridgeStatus === BridgeStatus.Stopped) {\n console.log('Initializing bridge...');\n this.bridgeStatus = BridgeStatus.Starting;\n await GoBridge.initBridge();\n console.log('Bridge initialized.');\n this.bridgeStatus = BridgeStatus.Started;\n }\n }\n\n #getClient() {\n if (!this.clientInstance) {\n throw new Error('GoBridge client instance not initialized.');\n }\n\n return this.clientInstance;\n }\n\n async setRemote(remote: string): Promise<SetRemoteResponse> {\n const client = this.#getClient();\n const response = client.setRemote(new SetRemoteRequest({ remote }));\n return response;\n }\n\n async getRemote(): Promise<string> {\n const client = this.#getClient();\n const response = await client.getRemote(new GetRemoteRequest());\n return response.remote;\n }\n\n async signTx(\n txJson: string,\n address: Uint8Array,\n accountNumber: bigint = BigInt(0),\n sequenceNumber: bigint = BigInt(0),\n ): Promise<SignTxResponse> {\n const client = this.#getClient();\n const response = client.signTx({ txJson, address, accountNumber, sequenceNumber });\n return response;\n }\n\n async setChainID(chainId: string): Promise<SetChainIDResponse> {\n const client = this.#getClient();\n const response = client.setChainID(new SetChainIDRequest({ chainId }));\n return response;\n }\n\n async getChainID() {\n const client = this.#getClient();\n const response = await client.getChainID(new GetChainIDRequest());\n return response.chainId;\n }\n\n async createAccount(\n nameOrBech32: string,\n mnemonic: string,\n password: string,\n ): Promise<KeyInfo | undefined> {\n const client = this.#getClient();\n const reponse = await client.createAccount(\n new CreateAccountRequest({\n nameOrBech32,\n mnemonic,\n password,\n }),\n );\n return reponse.key;\n }\n\n async generateRecoveryPhrase() {\n const client = this.#getClient();\n const response = await client.generateRecoveryPhrase(new GenerateRecoveryPhraseRequest());\n return response.phrase;\n }\n\n async hasKeyByName(name: string) {\n const client = this.#getClient();\n const response = await client.hasKeyByName(new HasKeyByNameRequest({ name }));\n return response.has;\n }\n\n async hasKeyByAddress(address: Uint8Array) {\n const client = this.#getClient();\n const response = await client.hasKeyByAddress(new HasKeyByAddressRequest({ address }));\n return response.has;\n }\n\n async hasKeyByNameOrAddress(nameOrBech32: string) {\n const client = this.#getClient();\n const response = await client.hasKeyByNameOrAddress(\n new HasKeyByNameOrAddressRequest({ nameOrBech32 }),\n );\n return response.has;\n }\n\n async getKeyInfoByName(name: string): Promise<KeyInfo | undefined> {\n const client = this.#getClient();\n const response = await client.getKeyInfoByName(new GetKeyInfoByNameRequest({ name }));\n return response.key;\n }\n\n async getKeyInfoByAddress(address: Uint8Array): Promise<KeyInfo | undefined> {\n const client = this.#getClient();\n const response = await client.getKeyInfoByAddress(new GetKeyInfoByAddressRequest({ address }));\n return response.key;\n }\n\n async getKeyInfoByNameOrAddress(nameOrBech32: string): Promise<KeyInfo | undefined> {\n const client = this.#getClient();\n const response = await client.getKeyInfoByNameOrAddress(\n new GetKeyInfoByNameOrAddressRequest({ nameOrBech32 }),\n );\n return response.key;\n }\n\n async listKeyInfo(): Promise<KeyInfo[]> {\n const client = this.#getClient();\n const response = await client.listKeyInfo(new ListKeyInfoRequest());\n return response.keys;\n }\n\n async makeCallTx(\n packagePath: string,\n fnc: string,\n args: string[],\n gasFee: string,\n gasWanted: bigint,\n callerAddress?: Uint8Array,\n send?: string,\n memo?: string,\n ): Promise<MakeTxResponse> {\n const client = this.#getClient();\n const reponse = client.makeCallTx({\n gasFee,\n gasWanted,\n memo,\n callerAddress,\n msgs: [\n {\n packagePath,\n fnc,\n args,\n send,\n },\n ],\n });\n return reponse;\n }\n\n async selectAccount(nameOrBech32: string): Promise<SelectAccountResponse> {\n const client = this.#getClient();\n const response = client.selectAccount(\n new SelectAccountRequest({\n nameOrBech32,\n }),\n );\n return response;\n }\n\n async activateAccount(nameOrBech32: string): Promise<ActivateAccountResponse> {\n const client = this.#getClient();\n const response = client.activateAccount(\n new ActivateAccountRequest({\n nameOrBech32,\n }),\n );\n return response;\n }\n\n async getClient(): Promise<PromiseClient<typeof GnoNativeService>> {\n if (!this.clientInstance) {\n throw new Error('GoBridge client instance not initialized.');\n }\n return this.clientInstance;\n }\n\n isInitialized(): boolean {\n return this.clientInstance !== undefined;\n }\n\n async setPassword(password: string, address?: Uint8Array): Promise<SetPasswordResponse> {\n const client = this.#getClient();\n const response = client.setPassword(new SetPasswordRequest({ password, address }));\n return response;\n }\n\n async updatePassword(\n newPassword: string,\n addresses: Uint8Array[],\n ): Promise<UpdatePasswordResponse> {\n const client = this.#getClient();\n const response = client.updatePassword(new UpdatePasswordRequest({ newPassword, addresses }));\n return response;\n }\n\n async getActiveAccount(): Promise<GetActiveAccountResponse> {\n const client = this.#getClient();\n const response = client.getActiveAccount(new GetActiveAccountRequest());\n return response;\n }\n\n async getActivatedAccount(): Promise<GetActivatedAccountResponse> {\n const client = this.#getClient();\n const response = client.getActivatedAccount(new GetActivatedAccountRequest());\n return response;\n }\n\n async queryAccount(address: Uint8Array): Promise<QueryAccountResponse> {\n const client = this.#getClient();\n const reponse = client.queryAccount(new QueryAccountRequest({ address }));\n return reponse;\n }\n\n async deleteAccount(\n nameOrBech32: string,\n password: string | undefined,\n skipPassword: boolean,\n ): Promise<DeleteAccountResponse> {\n const client = this.#getClient();\n const response = client.deleteAccount(\n new DeleteAccountRequest({\n nameOrBech32,\n password,\n skipPassword,\n }),\n );\n return response;\n }\n\n async query(path: string, data: Uint8Array): Promise<QueryResponse> {\n const client = this.#getClient();\n const reponse = client.query(\n new QueryRequest({\n path,\n data,\n }),\n );\n return reponse;\n }\n\n async render(packagePath: string, args: string) {\n const client = this.#getClient();\n const reponse = await client.render(\n new RenderRequest({\n packagePath,\n args,\n }),\n );\n return reponse.result;\n }\n\n async qEval(packagePath: string, expression: string) {\n const client = this.#getClient();\n const reponse = await client.qEval(\n new QEvalRequest({\n packagePath,\n expression,\n }),\n );\n return reponse.result;\n }\n\n async call(\n packagePath: string,\n fnc: string,\n args: string[],\n gasFee: string,\n gasWanted: bigint,\n callerAddress?: Uint8Array,\n send?: string,\n memo?: string,\n ): Promise<AsyncIterable<CallResponse>> {\n const client = this.#getClient();\n const reponse = client.call(\n new CallRequest({\n gasFee,\n gasWanted,\n memo,\n callerAddress,\n msgs: [\n new MsgCall({\n packagePath,\n fnc,\n args,\n send,\n }),\n ],\n }),\n );\n return reponse;\n }\n\n async send(\n toAddress: Uint8Array,\n send: string,\n gasFee: string,\n gasWanted: bigint,\n callerAddress?: Uint8Array,\n memo?: string,\n ): Promise<AsyncIterable<SendResponse>> {\n const client = this.#getClient();\n const reponse = client.send(\n new SendRequest({\n gasFee,\n gasWanted,\n memo,\n callerAddress,\n msgs: [\n new MsgSend({\n toAddress,\n send,\n }),\n ],\n }),\n );\n return reponse;\n }\n\n async addressToBech32(address: Uint8Array) {\n const client = this.#getClient();\n const response = await client.addressToBech32(new AddressToBech32Request({ address }));\n return response.bech32Address;\n }\n\n async addressFromMnemonic(mnemonic: string) {\n const client = this.#getClient();\n const response = await client.addressFromMnemonic(new AddressFromMnemonicRequest({ mnemonic }));\n return response.address;\n }\n\n async addressFromBech32(bech32Address: string) {\n const client = this.#getClient();\n const response = await client.addressFromBech32(\n new AddressFromBech32Request({ bech32Address }),\n );\n return response.address;\n }\n\n async broadcastTxCommit(signedTxJson: string): Promise<AsyncIterable<BroadcastTxCommitResponse>> {\n const client = this.#getClient();\n const response = client.broadcastTxCommit({ signedTxJson });\n return response;\n }\n\n // // debug\n async hello(name: string) {\n const client = this.#getClient();\n const response = await client.hello(new HelloRequest({ name }));\n return response.greeting;\n }\n\n // // debug\n async helloStream(name: string): Promise<AsyncIterable<HelloStreamResponse>> {\n const client = this.#getClient();\n return client.helloStream(new HelloRequest({ name }));\n }\n\n // Go Bridge Interface:\n initBridge(): Promise<void> {\n return GoBridge.initBridge();\n }\n closeBridge(): Promise<void> {\n return GoBridge.closeBridge();\n }\n getTcpPort(): Promise<number> {\n return GoBridge.getTcpPort();\n }\n startGnokeyMobileService(): Promise<void> {\n return GoBridge.startGnokeyMobileService();\n }\n invokeGrpcMethod(method: string, jsonMessage: string): Promise<string> {\n return GoBridge.invokeGrpcMethod(method, jsonMessage);\n }\n createStreamClient(method: string, jsonMessage: string): Promise<string> {\n return GoBridge.createStreamClient(method, jsonMessage);\n }\n streamClientReceive(id: string): Promise<string> {\n return GoBridge.streamClientReceive(id);\n }\n closeStreamClient(id: string): Promise<void> {\n return GoBridge.closeStreamClient(id);\n }\n}\n"]}
|
package/build/api/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CallResponse, DeleteAccountResponse, GetActiveAccountResponse, GetActivatedAccountResponse, HelloStreamResponse, QueryAccountResponse, QueryResponse, SelectAccountResponse, ActivateAccountResponse, SendResponse, SetChainIDResponse, SetPasswordResponse, SetRemoteResponse, UpdatePasswordResponse, KeyInfo } from '@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb';
|
|
1
|
+
import { CallResponse, DeleteAccountResponse, GetActiveAccountResponse, GetActivatedAccountResponse, HelloStreamResponse, QueryAccountResponse, QueryResponse, SelectAccountResponse, ActivateAccountResponse, SendResponse, SetChainIDResponse, SetPasswordResponse, SetRemoteResponse, UpdatePasswordResponse, KeyInfo, SignTxResponse, MakeTxResponse, BroadcastTxCommitResponse } from '@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb';
|
|
2
2
|
export declare enum BridgeStatus {
|
|
3
3
|
Stopped = 0,
|
|
4
4
|
Starting = 1,
|
|
@@ -34,11 +34,14 @@ export interface GnoKeyApi {
|
|
|
34
34
|
query: (path: string, data: Uint8Array) => Promise<QueryResponse>;
|
|
35
35
|
render: (packagePath: string, args: string) => Promise<string>;
|
|
36
36
|
qEval: (packagePath: string, expression: string) => Promise<string>;
|
|
37
|
-
call: (packagePath: string, fnc: string, args: string[], gasFee: string, gasWanted:
|
|
38
|
-
send: (toAddress: Uint8Array, send: string, gasFee: string, gasWanted:
|
|
37
|
+
call: (packagePath: string, fnc: string, args: string[], gasFee: string, gasWanted: bigint, callerAddress?: Uint8Array, send?: string, memo?: string) => Promise<AsyncIterable<CallResponse>>;
|
|
38
|
+
send: (toAddress: Uint8Array, send: string, gasFee: string, gasWanted: bigint, callerAddress?: Uint8Array, memo?: string) => Promise<AsyncIterable<SendResponse>>;
|
|
39
39
|
addressToBech32: (address: Uint8Array) => Promise<string>;
|
|
40
40
|
addressFromMnemonic: (mnemonic: string) => Promise<Uint8Array>;
|
|
41
41
|
addressFromBech32: (bech32Address: string) => Promise<Uint8Array>;
|
|
42
|
+
signTx(txJson: string, address: Uint8Array, accountNumber?: bigint, sequenceNumber?: bigint): Promise<SignTxResponse>;
|
|
43
|
+
makeCallTx(packagePath: string, fnc: string, args: string[], gasFee: string, gasWanted: bigint, callerAddress?: Uint8Array, send?: string, memo?: string): Promise<MakeTxResponse>;
|
|
44
|
+
broadcastTxCommit(signedTxJson: string): Promise<AsyncIterable<BroadcastTxCommitResponse>>;
|
|
42
45
|
hello: (name: string) => Promise<string>;
|
|
43
46
|
helloStream: (name: string) => Promise<AsyncIterable<HelloStreamResponse>>;
|
|
44
47
|
}
|
package/build/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,OAAO,EACP,cAAc,EACd,cAAc,EACd,yBAAyB,EAC1B,MAAM,sDAAsD,CAAC;AAE9D,oBAAY,YAAY;IACtB,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,OAAO,IAAA;CACR;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IAEjB,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC1D,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,UAAU,E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,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/D,iBAAiB,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAClE,MAAM,CACJ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,UAAU,EACnB,aAAa,CAAC,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3B,UAAU,CACR,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,UAAU,EAC1B,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3B,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAE3F,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAC5E"}
|
package/build/api/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,qDAAO,CAAA;IACP,uDAAQ,CAAA;IACR,qDAAO,CAAA;AACT,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB","sourcesContent":["import {\n CallResponse,\n DeleteAccountResponse,\n GetActiveAccountResponse,\n GetActivatedAccountResponse,\n HelloStreamResponse,\n QueryAccountResponse,\n QueryResponse,\n SelectAccountResponse,\n ActivateAccountResponse,\n SendResponse,\n SetChainIDResponse,\n SetPasswordResponse,\n SetRemoteResponse,\n UpdatePasswordResponse,\n KeyInfo,\n SignTxResponse,\n MakeTxResponse,\n BroadcastTxCommitResponse,\n} from '@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb';\n\nexport enum BridgeStatus {\n Stopped,\n Starting,\n Started,\n}\n\nexport interface Config {\n remote: string;\n chain_id: string;\n // If true, initBridge also starts a Gnokey Mobile service. (Only needed for the Gnokey Mobile app.)\n start_gnokey_mobile_service?: boolean;\n}\n\nexport interface GnoKeyApi {\n setRemote: (remote: string) => Promise<SetRemoteResponse>;\n getRemote: () => Promise<string>;\n setChainID: (chainId: string) => Promise<SetChainIDResponse>;\n getChainID: () => Promise<string>;\n createAccount: (\n nameOrBech32: string,\n mnemonic: string,\n password: string,\n ) => Promise<KeyInfo | undefined>;\n generateRecoveryPhrase: () => Promise<string>;\n listKeyInfo: () => Promise<KeyInfo[]>;\n hasKeyByName: (name: string) => Promise<boolean>;\n hasKeyByAddress: (address: Uint8Array) => Promise<boolean>;\n hasKeyByNameOrAddress: (nameOrBech32: string) => Promise<boolean>;\n getKeyInfoByName: (name: string) => Promise<KeyInfo | undefined>;\n getKeyInfoByAddress: (address: Uint8Array) => Promise<KeyInfo | undefined>;\n getKeyInfoByNameOrAddress: (nameOrBech32: string) => Promise<KeyInfo | undefined>;\n selectAccount: (nameOrBech32: string) => Promise<SelectAccountResponse>;\n activateAccount: (nameOrBech32: string) => Promise<ActivateAccountResponse>;\n setPassword: (password: string, address?: Uint8Array) => Promise<SetPasswordResponse>;\n updatePassword: (password: string, addresses: Uint8Array[]) => Promise<UpdatePasswordResponse>;\n getActiveAccount: () => Promise<GetActiveAccountResponse>;\n getActivatedAccount: () => Promise<GetActivatedAccountResponse>;\n queryAccount: (address: Uint8Array) => Promise<QueryAccountResponse>;\n deleteAccount: (\n nameOrBech32: string,\n password: string | undefined,\n skipPassword: boolean,\n ) => Promise<DeleteAccountResponse>;\n query: (path: string, data: Uint8Array) => Promise<QueryResponse>;\n render: (packagePath: string, args: string) => Promise<string>;\n qEval: (packagePath: string, expression: string) => Promise<string>;\n call: (\n packagePath: string,\n fnc: string,\n args: string[],\n gasFee: string,\n gasWanted: bigint,\n callerAddress?: Uint8Array,\n send?: string,\n memo?: string,\n ) => Promise<AsyncIterable<CallResponse>>;\n send: (\n toAddress: Uint8Array,\n send: string,\n gasFee: string,\n gasWanted: bigint,\n callerAddress?: Uint8Array,\n memo?: string,\n ) => Promise<AsyncIterable<SendResponse>>;\n addressToBech32: (address: Uint8Array) => Promise<string>;\n addressFromMnemonic: (mnemonic: string) => Promise<Uint8Array>;\n addressFromBech32: (bech32Address: string) => Promise<Uint8Array>;\n signTx(\n txJson: string,\n address: Uint8Array,\n accountNumber?: bigint,\n sequenceNumber?: bigint,\n ): Promise<SignTxResponse>;\n makeCallTx(\n packagePath: string,\n fnc: string,\n args: string[],\n gasFee: string,\n gasWanted: bigint,\n callerAddress?: Uint8Array,\n send?: string,\n memo?: string,\n ): Promise<MakeTxResponse>;\n broadcastTxCommit(signedTxJson: string): Promise<AsyncIterable<BroadcastTxCommitResponse>>;\n // debug\n hello: (name: string) => Promise<string>;\n helloStream: (name: string) => Promise<AsyncIterable<HelloStreamResponse>>;\n}\n"]}
|
|
Binary file
|
|
Binary file
|
package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/Current/GnoCore
CHANGED
|
Binary file
|
package/ios/Frameworks/GnoCore.xcframework/ios-arm64_x86_64-simulator/GnoCore.framework/GnoCore
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/api/GnoNativeApi.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
AddressFromBech32Request,
|
|
3
3
|
AddressToBech32Request,
|
|
4
4
|
AddressFromMnemonicRequest,
|
|
5
|
+
BroadcastTxCommitResponse,
|
|
5
6
|
CallRequest,
|
|
6
7
|
CallResponse,
|
|
7
8
|
CreateAccountRequest,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
HelloStreamResponse,
|
|
25
26
|
KeyInfo,
|
|
26
27
|
ListKeyInfoRequest,
|
|
28
|
+
MakeTxResponse,
|
|
27
29
|
MsgCall,
|
|
28
30
|
MsgSend,
|
|
29
31
|
QEvalRequest,
|
|
@@ -44,6 +46,7 @@ import {
|
|
|
44
46
|
SetPasswordResponse,
|
|
45
47
|
SetRemoteRequest,
|
|
46
48
|
SetRemoteResponse,
|
|
49
|
+
SignTxResponse,
|
|
47
50
|
UpdatePasswordRequest,
|
|
48
51
|
UpdatePasswordResponse,
|
|
49
52
|
} from '@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb';
|
|
@@ -116,25 +119,36 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
async setRemote(remote: string): Promise<SetRemoteResponse> {
|
|
119
|
-
const client =
|
|
120
|
-
const response =
|
|
122
|
+
const client = this.#getClient();
|
|
123
|
+
const response = client.setRemote(new SetRemoteRequest({ remote }));
|
|
121
124
|
return response;
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
async getRemote(): Promise<string> {
|
|
125
|
-
const client =
|
|
128
|
+
const client = this.#getClient();
|
|
126
129
|
const response = await client.getRemote(new GetRemoteRequest());
|
|
127
130
|
return response.remote;
|
|
128
131
|
}
|
|
129
132
|
|
|
133
|
+
async signTx(
|
|
134
|
+
txJson: string,
|
|
135
|
+
address: Uint8Array,
|
|
136
|
+
accountNumber: bigint = BigInt(0),
|
|
137
|
+
sequenceNumber: bigint = BigInt(0),
|
|
138
|
+
): Promise<SignTxResponse> {
|
|
139
|
+
const client = this.#getClient();
|
|
140
|
+
const response = client.signTx({ txJson, address, accountNumber, sequenceNumber });
|
|
141
|
+
return response;
|
|
142
|
+
}
|
|
143
|
+
|
|
130
144
|
async setChainID(chainId: string): Promise<SetChainIDResponse> {
|
|
131
|
-
const client =
|
|
132
|
-
const response =
|
|
145
|
+
const client = this.#getClient();
|
|
146
|
+
const response = client.setChainID(new SetChainIDRequest({ chainId }));
|
|
133
147
|
return response;
|
|
134
148
|
}
|
|
135
149
|
|
|
136
150
|
async getChainID() {
|
|
137
|
-
const client =
|
|
151
|
+
const client = this.#getClient();
|
|
138
152
|
const response = await client.getChainID(new GetChainIDRequest());
|
|
139
153
|
return response.chainId;
|
|
140
154
|
}
|
|
@@ -144,7 +158,7 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
144
158
|
mnemonic: string,
|
|
145
159
|
password: string,
|
|
146
160
|
): Promise<KeyInfo | undefined> {
|
|
147
|
-
const client =
|
|
161
|
+
const client = this.#getClient();
|
|
148
162
|
const reponse = await client.createAccount(
|
|
149
163
|
new CreateAccountRequest({
|
|
150
164
|
nameOrBech32,
|
|
@@ -156,25 +170,25 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
156
170
|
}
|
|
157
171
|
|
|
158
172
|
async generateRecoveryPhrase() {
|
|
159
|
-
const client =
|
|
173
|
+
const client = this.#getClient();
|
|
160
174
|
const response = await client.generateRecoveryPhrase(new GenerateRecoveryPhraseRequest());
|
|
161
175
|
return response.phrase;
|
|
162
176
|
}
|
|
163
177
|
|
|
164
178
|
async hasKeyByName(name: string) {
|
|
165
|
-
const client =
|
|
179
|
+
const client = this.#getClient();
|
|
166
180
|
const response = await client.hasKeyByName(new HasKeyByNameRequest({ name }));
|
|
167
181
|
return response.has;
|
|
168
182
|
}
|
|
169
183
|
|
|
170
184
|
async hasKeyByAddress(address: Uint8Array) {
|
|
171
|
-
const client =
|
|
185
|
+
const client = this.#getClient();
|
|
172
186
|
const response = await client.hasKeyByAddress(new HasKeyByAddressRequest({ address }));
|
|
173
187
|
return response.has;
|
|
174
188
|
}
|
|
175
189
|
|
|
176
190
|
async hasKeyByNameOrAddress(nameOrBech32: string) {
|
|
177
|
-
const client =
|
|
191
|
+
const client = this.#getClient();
|
|
178
192
|
const response = await client.hasKeyByNameOrAddress(
|
|
179
193
|
new HasKeyByNameOrAddressRequest({ nameOrBech32 }),
|
|
180
194
|
);
|
|
@@ -182,19 +196,19 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
182
196
|
}
|
|
183
197
|
|
|
184
198
|
async getKeyInfoByName(name: string): Promise<KeyInfo | undefined> {
|
|
185
|
-
const client =
|
|
199
|
+
const client = this.#getClient();
|
|
186
200
|
const response = await client.getKeyInfoByName(new GetKeyInfoByNameRequest({ name }));
|
|
187
201
|
return response.key;
|
|
188
202
|
}
|
|
189
203
|
|
|
190
204
|
async getKeyInfoByAddress(address: Uint8Array): Promise<KeyInfo | undefined> {
|
|
191
|
-
const client =
|
|
205
|
+
const client = this.#getClient();
|
|
192
206
|
const response = await client.getKeyInfoByAddress(new GetKeyInfoByAddressRequest({ address }));
|
|
193
207
|
return response.key;
|
|
194
208
|
}
|
|
195
209
|
|
|
196
210
|
async getKeyInfoByNameOrAddress(nameOrBech32: string): Promise<KeyInfo | undefined> {
|
|
197
|
-
const client =
|
|
211
|
+
const client = this.#getClient();
|
|
198
212
|
const response = await client.getKeyInfoByNameOrAddress(
|
|
199
213
|
new GetKeyInfoByNameOrAddressRequest({ nameOrBech32 }),
|
|
200
214
|
);
|
|
@@ -202,14 +216,42 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
202
216
|
}
|
|
203
217
|
|
|
204
218
|
async listKeyInfo(): Promise<KeyInfo[]> {
|
|
205
|
-
const client =
|
|
219
|
+
const client = this.#getClient();
|
|
206
220
|
const response = await client.listKeyInfo(new ListKeyInfoRequest());
|
|
207
221
|
return response.keys;
|
|
208
222
|
}
|
|
209
223
|
|
|
224
|
+
async makeCallTx(
|
|
225
|
+
packagePath: string,
|
|
226
|
+
fnc: string,
|
|
227
|
+
args: string[],
|
|
228
|
+
gasFee: string,
|
|
229
|
+
gasWanted: bigint,
|
|
230
|
+
callerAddress?: Uint8Array,
|
|
231
|
+
send?: string,
|
|
232
|
+
memo?: string,
|
|
233
|
+
): Promise<MakeTxResponse> {
|
|
234
|
+
const client = this.#getClient();
|
|
235
|
+
const reponse = client.makeCallTx({
|
|
236
|
+
gasFee,
|
|
237
|
+
gasWanted,
|
|
238
|
+
memo,
|
|
239
|
+
callerAddress,
|
|
240
|
+
msgs: [
|
|
241
|
+
{
|
|
242
|
+
packagePath,
|
|
243
|
+
fnc,
|
|
244
|
+
args,
|
|
245
|
+
send,
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
});
|
|
249
|
+
return reponse;
|
|
250
|
+
}
|
|
251
|
+
|
|
210
252
|
async selectAccount(nameOrBech32: string): Promise<SelectAccountResponse> {
|
|
211
|
-
const client =
|
|
212
|
-
const response =
|
|
253
|
+
const client = this.#getClient();
|
|
254
|
+
const response = client.selectAccount(
|
|
213
255
|
new SelectAccountRequest({
|
|
214
256
|
nameOrBech32,
|
|
215
257
|
}),
|
|
@@ -218,8 +260,8 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
218
260
|
}
|
|
219
261
|
|
|
220
262
|
async activateAccount(nameOrBech32: string): Promise<ActivateAccountResponse> {
|
|
221
|
-
const client =
|
|
222
|
-
const response =
|
|
263
|
+
const client = this.#getClient();
|
|
264
|
+
const response = client.activateAccount(
|
|
223
265
|
new ActivateAccountRequest({
|
|
224
266
|
nameOrBech32,
|
|
225
267
|
}),
|
|
@@ -239,32 +281,35 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
239
281
|
}
|
|
240
282
|
|
|
241
283
|
async setPassword(password: string, address?: Uint8Array): Promise<SetPasswordResponse> {
|
|
242
|
-
const client =
|
|
243
|
-
const response =
|
|
284
|
+
const client = this.#getClient();
|
|
285
|
+
const response = client.setPassword(new SetPasswordRequest({ password, address }));
|
|
244
286
|
return response;
|
|
245
287
|
}
|
|
246
288
|
|
|
247
|
-
async updatePassword(
|
|
248
|
-
|
|
249
|
-
|
|
289
|
+
async updatePassword(
|
|
290
|
+
newPassword: string,
|
|
291
|
+
addresses: Uint8Array[],
|
|
292
|
+
): Promise<UpdatePasswordResponse> {
|
|
293
|
+
const client = this.#getClient();
|
|
294
|
+
const response = client.updatePassword(new UpdatePasswordRequest({ newPassword, addresses }));
|
|
250
295
|
return response;
|
|
251
296
|
}
|
|
252
297
|
|
|
253
298
|
async getActiveAccount(): Promise<GetActiveAccountResponse> {
|
|
254
|
-
const client =
|
|
255
|
-
const response =
|
|
299
|
+
const client = this.#getClient();
|
|
300
|
+
const response = client.getActiveAccount(new GetActiveAccountRequest());
|
|
256
301
|
return response;
|
|
257
302
|
}
|
|
258
303
|
|
|
259
304
|
async getActivatedAccount(): Promise<GetActivatedAccountResponse> {
|
|
260
|
-
const client =
|
|
261
|
-
const response =
|
|
305
|
+
const client = this.#getClient();
|
|
306
|
+
const response = client.getActivatedAccount(new GetActivatedAccountRequest());
|
|
262
307
|
return response;
|
|
263
308
|
}
|
|
264
309
|
|
|
265
310
|
async queryAccount(address: Uint8Array): Promise<QueryAccountResponse> {
|
|
266
|
-
const client =
|
|
267
|
-
const reponse =
|
|
311
|
+
const client = this.#getClient();
|
|
312
|
+
const reponse = client.queryAccount(new QueryAccountRequest({ address }));
|
|
268
313
|
return reponse;
|
|
269
314
|
}
|
|
270
315
|
|
|
@@ -273,8 +318,8 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
273
318
|
password: string | undefined,
|
|
274
319
|
skipPassword: boolean,
|
|
275
320
|
): Promise<DeleteAccountResponse> {
|
|
276
|
-
const client =
|
|
277
|
-
const response =
|
|
321
|
+
const client = this.#getClient();
|
|
322
|
+
const response = client.deleteAccount(
|
|
278
323
|
new DeleteAccountRequest({
|
|
279
324
|
nameOrBech32,
|
|
280
325
|
password,
|
|
@@ -285,8 +330,8 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
285
330
|
}
|
|
286
331
|
|
|
287
332
|
async query(path: string, data: Uint8Array): Promise<QueryResponse> {
|
|
288
|
-
const client =
|
|
289
|
-
const reponse =
|
|
333
|
+
const client = this.#getClient();
|
|
334
|
+
const reponse = client.query(
|
|
290
335
|
new QueryRequest({
|
|
291
336
|
path,
|
|
292
337
|
data,
|
|
@@ -296,7 +341,7 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
296
341
|
}
|
|
297
342
|
|
|
298
343
|
async render(packagePath: string, args: string) {
|
|
299
|
-
const client =
|
|
344
|
+
const client = this.#getClient();
|
|
300
345
|
const reponse = await client.render(
|
|
301
346
|
new RenderRequest({
|
|
302
347
|
packagePath,
|
|
@@ -307,7 +352,7 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
307
352
|
}
|
|
308
353
|
|
|
309
354
|
async qEval(packagePath: string, expression: string) {
|
|
310
|
-
const client =
|
|
355
|
+
const client = this.#getClient();
|
|
311
356
|
const reponse = await client.qEval(
|
|
312
357
|
new QEvalRequest({
|
|
313
358
|
packagePath,
|
|
@@ -322,16 +367,16 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
322
367
|
fnc: string,
|
|
323
368
|
args: string[],
|
|
324
369
|
gasFee: string,
|
|
325
|
-
gasWanted:
|
|
370
|
+
gasWanted: bigint,
|
|
326
371
|
callerAddress?: Uint8Array,
|
|
327
372
|
send?: string,
|
|
328
373
|
memo?: string,
|
|
329
374
|
): Promise<AsyncIterable<CallResponse>> {
|
|
330
|
-
const client =
|
|
375
|
+
const client = this.#getClient();
|
|
331
376
|
const reponse = client.call(
|
|
332
377
|
new CallRequest({
|
|
333
378
|
gasFee,
|
|
334
|
-
gasWanted
|
|
379
|
+
gasWanted,
|
|
335
380
|
memo,
|
|
336
381
|
callerAddress,
|
|
337
382
|
msgs: [
|
|
@@ -351,15 +396,15 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
351
396
|
toAddress: Uint8Array,
|
|
352
397
|
send: string,
|
|
353
398
|
gasFee: string,
|
|
354
|
-
gasWanted:
|
|
399
|
+
gasWanted: bigint,
|
|
355
400
|
callerAddress?: Uint8Array,
|
|
356
401
|
memo?: string,
|
|
357
402
|
): Promise<AsyncIterable<SendResponse>> {
|
|
358
|
-
const client =
|
|
403
|
+
const client = this.#getClient();
|
|
359
404
|
const reponse = client.send(
|
|
360
405
|
new SendRequest({
|
|
361
406
|
gasFee,
|
|
362
|
-
gasWanted
|
|
407
|
+
gasWanted,
|
|
363
408
|
memo,
|
|
364
409
|
callerAddress,
|
|
365
410
|
msgs: [
|
|
@@ -374,35 +419,41 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
374
419
|
}
|
|
375
420
|
|
|
376
421
|
async addressToBech32(address: Uint8Array) {
|
|
377
|
-
const client =
|
|
422
|
+
const client = this.#getClient();
|
|
378
423
|
const response = await client.addressToBech32(new AddressToBech32Request({ address }));
|
|
379
424
|
return response.bech32Address;
|
|
380
425
|
}
|
|
381
426
|
|
|
382
427
|
async addressFromMnemonic(mnemonic: string) {
|
|
383
|
-
const client =
|
|
428
|
+
const client = this.#getClient();
|
|
384
429
|
const response = await client.addressFromMnemonic(new AddressFromMnemonicRequest({ mnemonic }));
|
|
385
430
|
return response.address;
|
|
386
431
|
}
|
|
387
432
|
|
|
388
433
|
async addressFromBech32(bech32Address: string) {
|
|
389
|
-
const client =
|
|
434
|
+
const client = this.#getClient();
|
|
390
435
|
const response = await client.addressFromBech32(
|
|
391
436
|
new AddressFromBech32Request({ bech32Address }),
|
|
392
437
|
);
|
|
393
438
|
return response.address;
|
|
394
439
|
}
|
|
395
440
|
|
|
441
|
+
async broadcastTxCommit(signedTxJson: string): Promise<AsyncIterable<BroadcastTxCommitResponse>> {
|
|
442
|
+
const client = this.#getClient();
|
|
443
|
+
const response = client.broadcastTxCommit({ signedTxJson });
|
|
444
|
+
return response;
|
|
445
|
+
}
|
|
446
|
+
|
|
396
447
|
// // debug
|
|
397
448
|
async hello(name: string) {
|
|
398
|
-
const client =
|
|
449
|
+
const client = this.#getClient();
|
|
399
450
|
const response = await client.hello(new HelloRequest({ name }));
|
|
400
451
|
return response.greeting;
|
|
401
452
|
}
|
|
402
453
|
|
|
403
454
|
// // debug
|
|
404
455
|
async helloStream(name: string): Promise<AsyncIterable<HelloStreamResponse>> {
|
|
405
|
-
const client =
|
|
456
|
+
const client = this.#getClient();
|
|
406
457
|
return client.helloStream(new HelloRequest({ name }));
|
|
407
458
|
}
|
|
408
459
|
|
package/src/api/types.ts
CHANGED
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
SetRemoteResponse,
|
|
15
15
|
UpdatePasswordResponse,
|
|
16
16
|
KeyInfo,
|
|
17
|
+
SignTxResponse,
|
|
18
|
+
MakeTxResponse,
|
|
19
|
+
BroadcastTxCommitResponse,
|
|
17
20
|
} from '@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb';
|
|
18
21
|
|
|
19
22
|
export enum BridgeStatus {
|
|
@@ -67,7 +70,7 @@ export interface GnoKeyApi {
|
|
|
67
70
|
fnc: string,
|
|
68
71
|
args: string[],
|
|
69
72
|
gasFee: string,
|
|
70
|
-
gasWanted:
|
|
73
|
+
gasWanted: bigint,
|
|
71
74
|
callerAddress?: Uint8Array,
|
|
72
75
|
send?: string,
|
|
73
76
|
memo?: string,
|
|
@@ -76,13 +79,30 @@ export interface GnoKeyApi {
|
|
|
76
79
|
toAddress: Uint8Array,
|
|
77
80
|
send: string,
|
|
78
81
|
gasFee: string,
|
|
79
|
-
gasWanted:
|
|
82
|
+
gasWanted: bigint,
|
|
80
83
|
callerAddress?: Uint8Array,
|
|
81
84
|
memo?: string,
|
|
82
85
|
) => Promise<AsyncIterable<SendResponse>>;
|
|
83
86
|
addressToBech32: (address: Uint8Array) => Promise<string>;
|
|
84
87
|
addressFromMnemonic: (mnemonic: string) => Promise<Uint8Array>;
|
|
85
88
|
addressFromBech32: (bech32Address: string) => Promise<Uint8Array>;
|
|
89
|
+
signTx(
|
|
90
|
+
txJson: string,
|
|
91
|
+
address: Uint8Array,
|
|
92
|
+
accountNumber?: bigint,
|
|
93
|
+
sequenceNumber?: bigint,
|
|
94
|
+
): Promise<SignTxResponse>;
|
|
95
|
+
makeCallTx(
|
|
96
|
+
packagePath: string,
|
|
97
|
+
fnc: string,
|
|
98
|
+
args: string[],
|
|
99
|
+
gasFee: string,
|
|
100
|
+
gasWanted: bigint,
|
|
101
|
+
callerAddress?: Uint8Array,
|
|
102
|
+
send?: string,
|
|
103
|
+
memo?: string,
|
|
104
|
+
): Promise<MakeTxResponse>;
|
|
105
|
+
broadcastTxCommit(signedTxJson: string): Promise<AsyncIterable<BroadcastTxCommitResponse>>;
|
|
86
106
|
// debug
|
|
87
107
|
hello: (name: string) => Promise<string>;
|
|
88
108
|
helloStream: (name: string) => Promise<AsyncIterable<HelloStreamResponse>>;
|