@gnolang/gnonative 4.0.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/Makefile +20 -3
- package/android/libs/gnocore-sources.jar +0 -0
- package/android/libs/gnocore.aar +0 -0
- package/android/src/main/java/land/gno/gnonative/GnonativeModule.kt +0 -13
- package/build/GoBridge.d.ts +0 -1
- package/build/GoBridge.d.ts.map +1 -1
- package/build/GoBridge.js +0 -3
- package/build/GoBridge.js.map +1 -1
- package/build/api/GnoNativeApi.d.ts +6 -6
- package/build/api/GnoNativeApi.d.ts.map +1 -1
- package/build/api/GnoNativeApi.js +50 -61
- package/build/api/GnoNativeApi.js.map +1 -1
- package/build/api/types.d.ts +2 -2
- package/build/api/types.d.ts.map +1 -1
- package/build/api/types.js.map +1 -1
- package/build/api/vendor/gnonativetypes_pb.d.ts +1334 -0
- package/build/api/vendor/gnonativetypes_pb.d.ts.map +1 -0
- package/build/api/vendor/gnonativetypes_pb.js +379 -0
- package/build/api/vendor/gnonativetypes_pb.js.map +1 -0
- package/build/api/vendor/rpc_pb.d.ts +646 -0
- package/build/api/vendor/rpc_pb.d.ts.map +1 -0
- package/build/api/vendor/rpc_pb.js +227 -0
- package/build/api/vendor/rpc_pb.js.map +1 -0
- 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/error.d.ts +1 -1
- package/build/grpc/error.d.ts.map +1 -1
- package/build/grpc/error.js +1 -1
- package/build/grpc/error.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/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/ios/Frameworks/GnoCore.xcframework/Info.plist +5 -5
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Headers/GnoGnonative.objc.h +0 -7
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/A/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/A/Headers/GnoGnonative.objc.h +0 -7
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/Current/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/Current/Headers/GnoGnonative.objc.h +0 -7
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64_x86_64-simulator/GnoCore.framework/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64_x86_64-simulator/GnoCore.framework/Headers/GnoGnonative.objc.h +0 -7
- package/ios/GnonativeModule.swift +0 -12
- package/package.json +4 -6
- package/src/GoBridge.ts +0 -5
- package/src/api/GnoNativeApi.ts +87 -142
- package/src/api/types.ts +10 -3
- package/src/api/vendor/gnonativetypes_pb.ts +1627 -0
- package/src/api/vendor/rpc_pb.ts +697 -0
- package/src/grpc/client.ts +4 -4
- package/src/grpc/error.ts +2 -1
- package/src/grpc/transport_native.ts +35 -36
- package/src/index.ts +2 -2
- package/tsconfig.json +0 -1
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>GnoCore.framework/Versions/A/GnoCore</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>ios-
|
|
11
|
+
<string>ios-arm64</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>GnoCore.framework</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
15
15
|
<array>
|
|
16
16
|
<string>arm64</string>
|
|
17
|
-
<string>x86_64</string>
|
|
18
17
|
</array>
|
|
19
18
|
<key>SupportedPlatform</key>
|
|
20
19
|
<string>ios</string>
|
|
21
|
-
<key>SupportedPlatformVariant</key>
|
|
22
|
-
<string>simulator</string>
|
|
23
20
|
</dict>
|
|
24
21
|
<dict>
|
|
25
22
|
<key>BinaryPath</key>
|
|
26
23
|
<string>GnoCore.framework/Versions/A/GnoCore</string>
|
|
27
24
|
<key>LibraryIdentifier</key>
|
|
28
|
-
<string>ios-
|
|
25
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
29
26
|
<key>LibraryPath</key>
|
|
30
27
|
<string>GnoCore.framework</string>
|
|
31
28
|
<key>SupportedArchitectures</key>
|
|
32
29
|
<array>
|
|
33
30
|
<string>arm64</string>
|
|
31
|
+
<string>x86_64</string>
|
|
34
32
|
</array>
|
|
35
33
|
<key>SupportedPlatform</key>
|
|
36
34
|
<string>ios</string>
|
|
35
|
+
<key>SupportedPlatformVariant</key>
|
|
36
|
+
<string>simulator</string>
|
|
37
37
|
</dict>
|
|
38
38
|
</array>
|
|
39
39
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Headers/GnoGnonative.objc.h
CHANGED
|
@@ -44,12 +44,6 @@
|
|
|
44
44
|
- (long)getTcpPort;
|
|
45
45
|
- (NSString* _Nonnull)getUDSPath;
|
|
46
46
|
- (void)invokeGrpcMethodWithPromiseBlock:(id<GnoGnonativePromiseBlock> _Nullable)promise method:(NSString* _Nullable)method jsonMessage:(NSString* _Nullable)jsonMessage;
|
|
47
|
-
/**
|
|
48
|
-
* Start the Gnokey Mobile service and save it in gnokeyMobileService. This will be closed in Close().
|
|
49
|
-
If the gnonative serviceServer is not started, do nothing.
|
|
50
|
-
If gnokeyMobileService is already started, do nothing.
|
|
51
|
-
*/
|
|
52
|
-
- (BOOL)startGnokeyMobileService:(NSError* _Nullable* _Nullable)error;
|
|
53
47
|
- (void)streamClientReceiveWithPromiseBlock:(id<GnoGnonativePromiseBlock> _Nullable)promise id_:(NSString* _Nullable)id_;
|
|
54
48
|
@end
|
|
55
49
|
|
|
@@ -63,7 +57,6 @@ If gnokeyMobileService is already started, do nothing.
|
|
|
63
57
|
@property (nonatomic) NSString* _Nonnull tmpDir;
|
|
64
58
|
@property (nonatomic) BOOL useTcpListener;
|
|
65
59
|
@property (nonatomic) BOOL disableUdsListener;
|
|
66
|
-
@property (nonatomic) BOOL useGnokeyMobile;
|
|
67
60
|
@end
|
|
68
61
|
|
|
69
62
|
FOUNDATION_EXPORT GnoGnonativeBridge* _Nullable GnoGnonativeNewBridge(GnoGnonativeBridgeConfig* _Nullable config, NSError* _Nullable* _Nullable error);
|
|
Binary file
|
|
@@ -44,12 +44,6 @@
|
|
|
44
44
|
- (long)getTcpPort;
|
|
45
45
|
- (NSString* _Nonnull)getUDSPath;
|
|
46
46
|
- (void)invokeGrpcMethodWithPromiseBlock:(id<GnoGnonativePromiseBlock> _Nullable)promise method:(NSString* _Nullable)method jsonMessage:(NSString* _Nullable)jsonMessage;
|
|
47
|
-
/**
|
|
48
|
-
* Start the Gnokey Mobile service and save it in gnokeyMobileService. This will be closed in Close().
|
|
49
|
-
If the gnonative serviceServer is not started, do nothing.
|
|
50
|
-
If gnokeyMobileService is already started, do nothing.
|
|
51
|
-
*/
|
|
52
|
-
- (BOOL)startGnokeyMobileService:(NSError* _Nullable* _Nullable)error;
|
|
53
47
|
- (void)streamClientReceiveWithPromiseBlock:(id<GnoGnonativePromiseBlock> _Nullable)promise id_:(NSString* _Nullable)id_;
|
|
54
48
|
@end
|
|
55
49
|
|
|
@@ -63,7 +57,6 @@ If gnokeyMobileService is already started, do nothing.
|
|
|
63
57
|
@property (nonatomic) NSString* _Nonnull tmpDir;
|
|
64
58
|
@property (nonatomic) BOOL useTcpListener;
|
|
65
59
|
@property (nonatomic) BOOL disableUdsListener;
|
|
66
|
-
@property (nonatomic) BOOL useGnokeyMobile;
|
|
67
60
|
@end
|
|
68
61
|
|
|
69
62
|
FOUNDATION_EXPORT GnoGnonativeBridge* _Nullable GnoGnonativeNewBridge(GnoGnonativeBridgeConfig* _Nullable config, NSError* _Nullable* _Nullable error);
|
package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/Current/GnoCore
CHANGED
|
Binary file
|
|
@@ -44,12 +44,6 @@
|
|
|
44
44
|
- (long)getTcpPort;
|
|
45
45
|
- (NSString* _Nonnull)getUDSPath;
|
|
46
46
|
- (void)invokeGrpcMethodWithPromiseBlock:(id<GnoGnonativePromiseBlock> _Nullable)promise method:(NSString* _Nullable)method jsonMessage:(NSString* _Nullable)jsonMessage;
|
|
47
|
-
/**
|
|
48
|
-
* Start the Gnokey Mobile service and save it in gnokeyMobileService. This will be closed in Close().
|
|
49
|
-
If the gnonative serviceServer is not started, do nothing.
|
|
50
|
-
If gnokeyMobileService is already started, do nothing.
|
|
51
|
-
*/
|
|
52
|
-
- (BOOL)startGnokeyMobileService:(NSError* _Nullable* _Nullable)error;
|
|
53
47
|
- (void)streamClientReceiveWithPromiseBlock:(id<GnoGnonativePromiseBlock> _Nullable)promise id_:(NSString* _Nullable)id_;
|
|
54
48
|
@end
|
|
55
49
|
|
|
@@ -63,7 +57,6 @@ If gnokeyMobileService is already started, do nothing.
|
|
|
63
57
|
@property (nonatomic) NSString* _Nonnull tmpDir;
|
|
64
58
|
@property (nonatomic) BOOL useTcpListener;
|
|
65
59
|
@property (nonatomic) BOOL disableUdsListener;
|
|
66
|
-
@property (nonatomic) BOOL useGnokeyMobile;
|
|
67
60
|
@end
|
|
68
61
|
|
|
69
62
|
FOUNDATION_EXPORT GnoGnonativeBridge* _Nullable GnoGnonativeNewBridge(GnoGnonativeBridgeConfig* _Nullable config, NSError* _Nullable* _Nullable error);
|
package/ios/Frameworks/GnoCore.xcframework/ios-arm64_x86_64-simulator/GnoCore.framework/GnoCore
CHANGED
|
Binary file
|
|
@@ -44,12 +44,6 @@
|
|
|
44
44
|
- (long)getTcpPort;
|
|
45
45
|
- (NSString* _Nonnull)getUDSPath;
|
|
46
46
|
- (void)invokeGrpcMethodWithPromiseBlock:(id<GnoGnonativePromiseBlock> _Nullable)promise method:(NSString* _Nullable)method jsonMessage:(NSString* _Nullable)jsonMessage;
|
|
47
|
-
/**
|
|
48
|
-
* Start the Gnokey Mobile service and save it in gnokeyMobileService. This will be closed in Close().
|
|
49
|
-
If the gnonative serviceServer is not started, do nothing.
|
|
50
|
-
If gnokeyMobileService is already started, do nothing.
|
|
51
|
-
*/
|
|
52
|
-
- (BOOL)startGnokeyMobileService:(NSError* _Nullable* _Nullable)error;
|
|
53
47
|
- (void)streamClientReceiveWithPromiseBlock:(id<GnoGnonativePromiseBlock> _Nullable)promise id_:(NSString* _Nullable)id_;
|
|
54
48
|
@end
|
|
55
49
|
|
|
@@ -63,7 +57,6 @@ If gnokeyMobileService is already started, do nothing.
|
|
|
63
57
|
@property (nonatomic) NSString* _Nonnull tmpDir;
|
|
64
58
|
@property (nonatomic) BOOL useTcpListener;
|
|
65
59
|
@property (nonatomic) BOOL disableUdsListener;
|
|
66
|
-
@property (nonatomic) BOOL useGnokeyMobile;
|
|
67
60
|
@end
|
|
68
61
|
|
|
69
62
|
FOUNDATION_EXPORT GnoGnonativeBridge* _Nullable GnoGnonativeNewBridge(GnoGnonativeBridgeConfig* _Nullable config, NSError* _Nullable* _Nullable error);
|
|
@@ -92,18 +92,6 @@ public class GnonativeModule: Module {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
AsyncFunction("startGnokeyMobileService") { (promise: Promise) in
|
|
96
|
-
do {
|
|
97
|
-
guard let service = self.bridge else {
|
|
98
|
-
throw GnoError(.notStarted)
|
|
99
|
-
}
|
|
100
|
-
try service.startGnokeyMobileService()
|
|
101
|
-
promise.resolve(true)
|
|
102
|
-
} catch let error {
|
|
103
|
-
promise.reject(error)
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
95
|
AsyncFunction("closeBridge") { (promise: Promise) in
|
|
108
96
|
do {
|
|
109
97
|
guard let service = self.bridge else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnolang/gnonative",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Develop for Gno using your app's native language ",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,11 +29,9 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"homepage": "https://github.com/gnolang/gnonative#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@connectrpc/connect": "^1.4.0",
|
|
36
|
-
"@connectrpc/connect-web": "^1.4.0",
|
|
32
|
+
"@bufbuild/protobuf": "^2.2.5",
|
|
33
|
+
"@connectrpc/connect": "^2.0.2",
|
|
34
|
+
"@connectrpc/connect-web": "^2.0.2",
|
|
37
35
|
"base64-js": "^1.5.1",
|
|
38
36
|
"fast-text-encoding": "^1.0.6"
|
|
39
37
|
},
|
package/src/GoBridge.ts
CHANGED
|
@@ -4,7 +4,6 @@ export interface GoBridgeInterface {
|
|
|
4
4
|
initBridge(): Promise<void>;
|
|
5
5
|
closeBridge(): Promise<void>;
|
|
6
6
|
getTcpPort(): Promise<number>;
|
|
7
|
-
startGnokeyMobileService(): Promise<void>;
|
|
8
7
|
invokeGrpcMethod(method: string, jsonMessage: string): Promise<string>;
|
|
9
8
|
createStreamClient(method: string, jsonMessage: string): Promise<string>;
|
|
10
9
|
streamClientReceive(id: string): Promise<string>;
|
|
@@ -24,10 +23,6 @@ class GoBridge implements GoBridgeInterface {
|
|
|
24
23
|
return GnonativeModule.getTcpPort();
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
startGnokeyMobileService(): Promise<void> {
|
|
28
|
-
return GnonativeModule.startGnokeyMobileService();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
26
|
invokeGrpcMethod(method: string, jsonMessage: string): Promise<string> {
|
|
32
27
|
return GnonativeModule.invokeGrpcMethod(method, jsonMessage);
|
|
33
28
|
}
|
package/src/api/GnoNativeApi.ts
CHANGED
|
@@ -1,63 +1,34 @@
|
|
|
1
|
+
import { Client } from '@connectrpc/connect';
|
|
2
|
+
|
|
3
|
+
import { GnoKeyApi, BridgeStatus, Config } from './types';
|
|
1
4
|
import {
|
|
2
|
-
AddressFromBech32Request,
|
|
3
|
-
AddressToBech32Request,
|
|
4
|
-
AddressFromMnemonicRequest,
|
|
5
5
|
BroadcastTxCommitResponse,
|
|
6
|
-
CallRequest,
|
|
7
6
|
CallResponse,
|
|
8
|
-
CreateAccountRequest,
|
|
9
|
-
DeleteAccountRequest,
|
|
10
7
|
DeleteAccountResponse,
|
|
11
|
-
GenerateRecoveryPhraseRequest,
|
|
12
|
-
GetActivatedAccountRequest,
|
|
13
8
|
GetActivatedAccountResponse,
|
|
14
|
-
GetChainIDRequest,
|
|
15
|
-
GetKeyInfoByAddressRequest,
|
|
16
|
-
GetKeyInfoByNameOrAddressRequest,
|
|
17
|
-
GetKeyInfoByNameRequest,
|
|
18
|
-
GetRemoteRequest,
|
|
19
|
-
HasKeyByAddressRequest,
|
|
20
|
-
HasKeyByNameOrAddressRequest,
|
|
21
|
-
HasKeyByNameRequest,
|
|
22
|
-
HelloRequest,
|
|
23
9
|
HelloStreamResponse,
|
|
24
10
|
KeyInfo,
|
|
25
|
-
ListKeyInfoRequest,
|
|
26
11
|
MakeTxResponse,
|
|
27
|
-
MsgCall,
|
|
28
12
|
Coin,
|
|
29
|
-
MsgSend,
|
|
30
|
-
QEvalRequest,
|
|
31
|
-
QueryAccountRequest,
|
|
32
13
|
QueryAccountResponse,
|
|
33
|
-
QueryRequest,
|
|
34
14
|
QueryResponse,
|
|
35
|
-
RenderRequest,
|
|
36
|
-
ActivateAccountRequest,
|
|
37
15
|
ActivateAccountResponse,
|
|
38
|
-
SendRequest,
|
|
39
16
|
SendResponse,
|
|
40
|
-
SetChainIDRequest,
|
|
41
17
|
SetChainIDResponse,
|
|
42
|
-
SetPasswordRequest,
|
|
43
18
|
SetPasswordResponse,
|
|
44
|
-
SetRemoteRequest,
|
|
45
19
|
SetRemoteResponse,
|
|
46
20
|
SignTxResponse,
|
|
47
|
-
RotatePasswordRequest,
|
|
48
21
|
RotatePasswordResponse,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
import {
|
|
52
|
-
|
|
53
|
-
import { GnoKeyApi, BridgeStatus, Config } from './types';
|
|
22
|
+
EstimateGasResponse,
|
|
23
|
+
} from './vendor/gnonativetypes_pb';
|
|
24
|
+
import { GnoNativeService } from './vendor/rpc_pb';
|
|
54
25
|
import { GoBridge, GoBridgeInterface } from '../GoBridge';
|
|
55
26
|
import * as Grpc from '../grpc/client';
|
|
56
27
|
|
|
57
28
|
export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
58
29
|
bridgeStatus = BridgeStatus.Stopped;
|
|
59
30
|
config: Config;
|
|
60
|
-
clientInstance:
|
|
31
|
+
clientInstance: Client<typeof GnoNativeService> | undefined;
|
|
61
32
|
|
|
62
33
|
constructor(config: Config) {
|
|
63
34
|
this.config = config;
|
|
@@ -81,15 +52,9 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
81
52
|
console.log('GoBridge GRPC client instance. Done.');
|
|
82
53
|
|
|
83
54
|
try {
|
|
84
|
-
await this.clientInstance
|
|
85
|
-
await this.clientInstance
|
|
86
|
-
new SetChainIDRequest({ chainId: this.config.chain_id }),
|
|
87
|
-
);
|
|
55
|
+
await this.clientInstance?.setRemote({ remote: this.config.remote });
|
|
56
|
+
await this.clientInstance?.setChainID({ chainId: this.config.chain_id });
|
|
88
57
|
console.log('✅ GnoNative bridge initialized.');
|
|
89
|
-
if (this.config.start_gnokey_mobile_service) {
|
|
90
|
-
await this.startGnokeyMobileService();
|
|
91
|
-
console.log('✅ Gnokey Mobile service started.');
|
|
92
|
-
}
|
|
93
58
|
return true;
|
|
94
59
|
} catch (error) {
|
|
95
60
|
console.error(error);
|
|
@@ -117,13 +82,13 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
117
82
|
|
|
118
83
|
async setRemote(remote: string): Promise<SetRemoteResponse> {
|
|
119
84
|
const client = this.#getClient();
|
|
120
|
-
const response = client.setRemote(
|
|
85
|
+
const response = client.setRemote({ remote });
|
|
121
86
|
return response;
|
|
122
87
|
}
|
|
123
88
|
|
|
124
89
|
async getRemote(): Promise<string> {
|
|
125
90
|
const client = this.#getClient();
|
|
126
|
-
const response = await client.getRemote(
|
|
91
|
+
const response = await client.getRemote({});
|
|
127
92
|
return response.remote;
|
|
128
93
|
}
|
|
129
94
|
|
|
@@ -138,15 +103,35 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
138
103
|
return response;
|
|
139
104
|
}
|
|
140
105
|
|
|
106
|
+
async estimateGas(
|
|
107
|
+
txJson: string,
|
|
108
|
+
address: Uint8Array,
|
|
109
|
+
securityMargin: number,
|
|
110
|
+
updateTx: boolean,
|
|
111
|
+
accountNumber: bigint = BigInt(0),
|
|
112
|
+
sequenceNumber: bigint = BigInt(0),
|
|
113
|
+
): Promise<EstimateGasResponse> {
|
|
114
|
+
const client = this.#getClient();
|
|
115
|
+
const response = client.estimateGas({
|
|
116
|
+
txJson,
|
|
117
|
+
address,
|
|
118
|
+
securityMargin,
|
|
119
|
+
updateTx,
|
|
120
|
+
accountNumber,
|
|
121
|
+
sequenceNumber,
|
|
122
|
+
});
|
|
123
|
+
return response;
|
|
124
|
+
}
|
|
125
|
+
|
|
141
126
|
async setChainID(chainId: string): Promise<SetChainIDResponse> {
|
|
142
127
|
const client = this.#getClient();
|
|
143
|
-
const response = client.setChainID(
|
|
128
|
+
const response = client.setChainID({ chainId });
|
|
144
129
|
return response;
|
|
145
130
|
}
|
|
146
131
|
|
|
147
132
|
async getChainID() {
|
|
148
133
|
const client = this.#getClient();
|
|
149
|
-
const response = await client.getChainID(
|
|
134
|
+
const response = await client.getChainID({});
|
|
150
135
|
return response.chainId;
|
|
151
136
|
}
|
|
152
137
|
|
|
@@ -156,65 +141,59 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
156
141
|
password: string,
|
|
157
142
|
): Promise<KeyInfo | undefined> {
|
|
158
143
|
const client = this.#getClient();
|
|
159
|
-
const reponse = await client.createAccount(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}),
|
|
165
|
-
);
|
|
144
|
+
const reponse = await client.createAccount({
|
|
145
|
+
nameOrBech32,
|
|
146
|
+
mnemonic,
|
|
147
|
+
password,
|
|
148
|
+
});
|
|
166
149
|
return reponse.key;
|
|
167
150
|
}
|
|
168
151
|
|
|
169
152
|
async generateRecoveryPhrase() {
|
|
170
153
|
const client = this.#getClient();
|
|
171
|
-
const response = await client.generateRecoveryPhrase(
|
|
154
|
+
const response = await client.generateRecoveryPhrase({});
|
|
172
155
|
return response.phrase;
|
|
173
156
|
}
|
|
174
157
|
|
|
175
158
|
async hasKeyByName(name: string) {
|
|
176
159
|
const client = this.#getClient();
|
|
177
|
-
const response = await client.hasKeyByName(
|
|
160
|
+
const response = await client.hasKeyByName({ name });
|
|
178
161
|
return response.has;
|
|
179
162
|
}
|
|
180
163
|
|
|
181
164
|
async hasKeyByAddress(address: Uint8Array) {
|
|
182
165
|
const client = this.#getClient();
|
|
183
|
-
const response = await client.hasKeyByAddress(
|
|
166
|
+
const response = await client.hasKeyByAddress({ address });
|
|
184
167
|
return response.has;
|
|
185
168
|
}
|
|
186
169
|
|
|
187
170
|
async hasKeyByNameOrAddress(nameOrBech32: string) {
|
|
188
171
|
const client = this.#getClient();
|
|
189
|
-
const response = await client.hasKeyByNameOrAddress(
|
|
190
|
-
new HasKeyByNameOrAddressRequest({ nameOrBech32 }),
|
|
191
|
-
);
|
|
172
|
+
const response = await client.hasKeyByNameOrAddress({ nameOrBech32 });
|
|
192
173
|
return response.has;
|
|
193
174
|
}
|
|
194
175
|
|
|
195
176
|
async getKeyInfoByName(name: string): Promise<KeyInfo | undefined> {
|
|
196
177
|
const client = this.#getClient();
|
|
197
|
-
const response = await client.getKeyInfoByName(
|
|
178
|
+
const response = await client.getKeyInfoByName({ name });
|
|
198
179
|
return response.key;
|
|
199
180
|
}
|
|
200
181
|
|
|
201
182
|
async getKeyInfoByAddress(address: Uint8Array): Promise<KeyInfo | undefined> {
|
|
202
183
|
const client = this.#getClient();
|
|
203
|
-
const response = await client.getKeyInfoByAddress(
|
|
184
|
+
const response = await client.getKeyInfoByAddress({ address });
|
|
204
185
|
return response.key;
|
|
205
186
|
}
|
|
206
187
|
|
|
207
188
|
async getKeyInfoByNameOrAddress(nameOrBech32: string): Promise<KeyInfo | undefined> {
|
|
208
189
|
const client = this.#getClient();
|
|
209
|
-
const response = await client.getKeyInfoByNameOrAddress(
|
|
210
|
-
new GetKeyInfoByNameOrAddressRequest({ nameOrBech32 }),
|
|
211
|
-
);
|
|
190
|
+
const response = await client.getKeyInfoByNameOrAddress({ nameOrBech32 });
|
|
212
191
|
return response.key;
|
|
213
192
|
}
|
|
214
193
|
|
|
215
194
|
async listKeyInfo(): Promise<KeyInfo[]> {
|
|
216
195
|
const client = this.#getClient();
|
|
217
|
-
const response = await client.listKeyInfo(
|
|
196
|
+
const response = await client.listKeyInfo({});
|
|
218
197
|
return response.keys;
|
|
219
198
|
}
|
|
220
199
|
|
|
@@ -272,15 +251,11 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
272
251
|
|
|
273
252
|
async activateAccount(nameOrBech32: string): Promise<ActivateAccountResponse> {
|
|
274
253
|
const client = this.#getClient();
|
|
275
|
-
const response = client.activateAccount(
|
|
276
|
-
new ActivateAccountRequest({
|
|
277
|
-
nameOrBech32,
|
|
278
|
-
}),
|
|
279
|
-
);
|
|
254
|
+
const response = client.activateAccount({ nameOrBech32 });
|
|
280
255
|
return response;
|
|
281
256
|
}
|
|
282
257
|
|
|
283
|
-
async getClient(): Promise<
|
|
258
|
+
async getClient(): Promise<Client<typeof GnoNativeService>> {
|
|
284
259
|
if (!this.clientInstance) {
|
|
285
260
|
throw new Error('GoBridge client instance not initialized.');
|
|
286
261
|
}
|
|
@@ -293,7 +268,7 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
293
268
|
|
|
294
269
|
async setPassword(password: string, address: Uint8Array): Promise<SetPasswordResponse> {
|
|
295
270
|
const client = this.#getClient();
|
|
296
|
-
const response = client.setPassword(
|
|
271
|
+
const response = client.setPassword({ password, address });
|
|
297
272
|
return response;
|
|
298
273
|
}
|
|
299
274
|
|
|
@@ -302,19 +277,19 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
302
277
|
addresses: Uint8Array[],
|
|
303
278
|
): Promise<RotatePasswordResponse> {
|
|
304
279
|
const client = this.#getClient();
|
|
305
|
-
const response = client.rotatePassword(
|
|
280
|
+
const response = client.rotatePassword({ newPassword, addresses });
|
|
306
281
|
return response;
|
|
307
282
|
}
|
|
308
283
|
|
|
309
284
|
async getActivatedAccount(): Promise<GetActivatedAccountResponse> {
|
|
310
285
|
const client = this.#getClient();
|
|
311
|
-
const response = client.getActivatedAccount(
|
|
286
|
+
const response = client.getActivatedAccount({});
|
|
312
287
|
return response;
|
|
313
288
|
}
|
|
314
289
|
|
|
315
290
|
async queryAccount(address: Uint8Array): Promise<QueryAccountResponse> {
|
|
316
291
|
const client = this.#getClient();
|
|
317
|
-
const reponse = client.queryAccount(
|
|
292
|
+
const reponse = client.queryAccount({ address });
|
|
318
293
|
return reponse;
|
|
319
294
|
}
|
|
320
295
|
|
|
@@ -324,46 +299,25 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
324
299
|
skipPassword: boolean,
|
|
325
300
|
): Promise<DeleteAccountResponse> {
|
|
326
301
|
const client = this.#getClient();
|
|
327
|
-
const response = client.deleteAccount(
|
|
328
|
-
new DeleteAccountRequest({
|
|
329
|
-
nameOrBech32,
|
|
330
|
-
password,
|
|
331
|
-
skipPassword,
|
|
332
|
-
}),
|
|
333
|
-
);
|
|
302
|
+
const response = client.deleteAccount({ nameOrBech32, password, skipPassword });
|
|
334
303
|
return response;
|
|
335
304
|
}
|
|
336
305
|
|
|
337
306
|
async query(path: string, data: Uint8Array): Promise<QueryResponse> {
|
|
338
307
|
const client = this.#getClient();
|
|
339
|
-
const reponse = client.query(
|
|
340
|
-
new QueryRequest({
|
|
341
|
-
path,
|
|
342
|
-
data,
|
|
343
|
-
}),
|
|
344
|
-
);
|
|
308
|
+
const reponse = client.query({ path, data });
|
|
345
309
|
return reponse;
|
|
346
310
|
}
|
|
347
311
|
|
|
348
312
|
async render(packagePath: string, args: string) {
|
|
349
313
|
const client = this.#getClient();
|
|
350
|
-
const reponse = await client.render(
|
|
351
|
-
new RenderRequest({
|
|
352
|
-
packagePath,
|
|
353
|
-
args,
|
|
354
|
-
}),
|
|
355
|
-
);
|
|
314
|
+
const reponse = await client.render({ packagePath, args });
|
|
356
315
|
return reponse.result;
|
|
357
316
|
}
|
|
358
317
|
|
|
359
318
|
async qEval(packagePath: string, expression: string) {
|
|
360
319
|
const client = this.#getClient();
|
|
361
|
-
const reponse = await client.qEval(
|
|
362
|
-
new QEvalRequest({
|
|
363
|
-
packagePath,
|
|
364
|
-
expression,
|
|
365
|
-
}),
|
|
366
|
-
);
|
|
320
|
+
const reponse = await client.qEval({ packagePath, expression });
|
|
367
321
|
return reponse.result;
|
|
368
322
|
}
|
|
369
323
|
|
|
@@ -378,22 +332,20 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
378
332
|
memo?: string,
|
|
379
333
|
): Promise<AsyncIterable<CallResponse>> {
|
|
380
334
|
const client = this.#getClient();
|
|
381
|
-
const reponse = client.call(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}),
|
|
396
|
-
);
|
|
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
|
+
});
|
|
397
349
|
return reponse;
|
|
398
350
|
}
|
|
399
351
|
|
|
@@ -406,40 +358,36 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
406
358
|
memo?: string,
|
|
407
359
|
): Promise<AsyncIterable<SendResponse>> {
|
|
408
360
|
const client = this.#getClient();
|
|
409
|
-
const reponse = client.send(
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}),
|
|
422
|
-
);
|
|
361
|
+
const reponse = client.send({
|
|
362
|
+
gasFee,
|
|
363
|
+
gasWanted,
|
|
364
|
+
memo,
|
|
365
|
+
callerAddress,
|
|
366
|
+
msgs: [
|
|
367
|
+
{
|
|
368
|
+
toAddress,
|
|
369
|
+
amount,
|
|
370
|
+
},
|
|
371
|
+
],
|
|
372
|
+
});
|
|
423
373
|
return reponse;
|
|
424
374
|
}
|
|
425
375
|
|
|
426
376
|
async addressToBech32(address: Uint8Array) {
|
|
427
377
|
const client = this.#getClient();
|
|
428
|
-
const response = await client.addressToBech32(
|
|
378
|
+
const response = await client.addressToBech32({ address });
|
|
429
379
|
return response.bech32Address;
|
|
430
380
|
}
|
|
431
381
|
|
|
432
382
|
async addressFromMnemonic(mnemonic: string) {
|
|
433
383
|
const client = this.#getClient();
|
|
434
|
-
const response = await client.addressFromMnemonic(
|
|
384
|
+
const response = await client.addressFromMnemonic({ mnemonic });
|
|
435
385
|
return response.address;
|
|
436
386
|
}
|
|
437
387
|
|
|
438
388
|
async addressFromBech32(bech32Address: string) {
|
|
439
389
|
const client = this.#getClient();
|
|
440
|
-
const response = await client.addressFromBech32(
|
|
441
|
-
new AddressFromBech32Request({ bech32Address }),
|
|
442
|
-
);
|
|
390
|
+
const response = await client.addressFromBech32({ bech32Address });
|
|
443
391
|
return response.address;
|
|
444
392
|
}
|
|
445
393
|
|
|
@@ -452,14 +400,14 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
452
400
|
// // debug
|
|
453
401
|
async hello(name: string) {
|
|
454
402
|
const client = this.#getClient();
|
|
455
|
-
const response = await client.hello(
|
|
403
|
+
const response = await client.hello({ name });
|
|
456
404
|
return response.greeting;
|
|
457
405
|
}
|
|
458
406
|
|
|
459
407
|
// // debug
|
|
460
408
|
async helloStream(name: string): Promise<AsyncIterable<HelloStreamResponse>> {
|
|
461
409
|
const client = this.#getClient();
|
|
462
|
-
return client.helloStream(
|
|
410
|
+
return client.helloStream({ name });
|
|
463
411
|
}
|
|
464
412
|
|
|
465
413
|
// Go Bridge Interface:
|
|
@@ -472,9 +420,6 @@ export class GnoNativeApi implements GnoKeyApi, GoBridgeInterface {
|
|
|
472
420
|
getTcpPort(): Promise<number> {
|
|
473
421
|
return GoBridge.getTcpPort();
|
|
474
422
|
}
|
|
475
|
-
startGnokeyMobileService(): Promise<void> {
|
|
476
|
-
return GoBridge.startGnokeyMobileService();
|
|
477
|
-
}
|
|
478
423
|
invokeGrpcMethod(method: string, jsonMessage: string): Promise<string> {
|
|
479
424
|
return GoBridge.invokeGrpcMethod(method, jsonMessage);
|
|
480
425
|
}
|
package/src/api/types.ts
CHANGED
|
@@ -13,10 +13,11 @@ import {
|
|
|
13
13
|
RotatePasswordResponse,
|
|
14
14
|
KeyInfo,
|
|
15
15
|
SignTxResponse,
|
|
16
|
+
EstimateGasResponse,
|
|
16
17
|
MakeTxResponse,
|
|
17
18
|
BroadcastTxCommitResponse,
|
|
18
19
|
Coin,
|
|
19
|
-
} from '
|
|
20
|
+
} from './vendor/gnonativetypes_pb';
|
|
20
21
|
|
|
21
22
|
export enum BridgeStatus {
|
|
22
23
|
Stopped,
|
|
@@ -27,8 +28,6 @@ export enum BridgeStatus {
|
|
|
27
28
|
export interface Config {
|
|
28
29
|
remote: string;
|
|
29
30
|
chain_id: string;
|
|
30
|
-
// If true, initBridge also starts a Gnokey Mobile service. (Only needed for the Gnokey Mobile app.)
|
|
31
|
-
start_gnokey_mobile_service?: boolean;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
export interface GnoKeyApi {
|
|
@@ -89,6 +88,14 @@ export interface GnoKeyApi {
|
|
|
89
88
|
accountNumber?: bigint,
|
|
90
89
|
sequenceNumber?: bigint,
|
|
91
90
|
): Promise<SignTxResponse>;
|
|
91
|
+
estimateGas(
|
|
92
|
+
txJson: string,
|
|
93
|
+
address: Uint8Array,
|
|
94
|
+
securityMargin: number,
|
|
95
|
+
updateTx: boolean,
|
|
96
|
+
accountNumber?: bigint,
|
|
97
|
+
sequenceNumber?: bigint,
|
|
98
|
+
): Promise<EstimateGasResponse>;
|
|
92
99
|
makeCallTx(
|
|
93
100
|
packagePath: string,
|
|
94
101
|
fnc: string,
|