@0xsequence/guard 1.1.0 → 1.1.2
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.
|
@@ -28,13 +28,13 @@ function _extends() {
|
|
|
28
28
|
// webrpc-gen -schema=guard.ridl -target=typescript -client -out=./clients/guard.gen.ts
|
|
29
29
|
|
|
30
30
|
// WebRPC description and code-gen version
|
|
31
|
-
const WebRPCVersion =
|
|
31
|
+
const WebRPCVersion = 'v1';
|
|
32
32
|
|
|
33
33
|
// Schema version of your RIDL schema
|
|
34
|
-
const WebRPCSchemaVersion =
|
|
34
|
+
const WebRPCSchemaVersion = 'v0.4.0';
|
|
35
35
|
|
|
36
36
|
// Schema hash generated from your RIDL schema
|
|
37
|
-
const WebRPCSchemaHash =
|
|
37
|
+
const WebRPCSchemaHash = 'a29651d1d5f63268e8d03b51e46557e0632c144d';
|
|
38
38
|
|
|
39
39
|
//
|
|
40
40
|
// Types
|
|
@@ -28,13 +28,13 @@ function _extends() {
|
|
|
28
28
|
// webrpc-gen -schema=guard.ridl -target=typescript -client -out=./clients/guard.gen.ts
|
|
29
29
|
|
|
30
30
|
// WebRPC description and code-gen version
|
|
31
|
-
const WebRPCVersion =
|
|
31
|
+
const WebRPCVersion = 'v1';
|
|
32
32
|
|
|
33
33
|
// Schema version of your RIDL schema
|
|
34
|
-
const WebRPCSchemaVersion =
|
|
34
|
+
const WebRPCSchemaVersion = 'v0.4.0';
|
|
35
35
|
|
|
36
36
|
// Schema hash generated from your RIDL schema
|
|
37
|
-
const WebRPCSchemaHash =
|
|
37
|
+
const WebRPCSchemaHash = 'a29651d1d5f63268e8d03b51e46557e0632c144d';
|
|
38
38
|
|
|
39
39
|
//
|
|
40
40
|
// Types
|
|
@@ -24,13 +24,13 @@ function _extends() {
|
|
|
24
24
|
// webrpc-gen -schema=guard.ridl -target=typescript -client -out=./clients/guard.gen.ts
|
|
25
25
|
|
|
26
26
|
// WebRPC description and code-gen version
|
|
27
|
-
const WebRPCVersion =
|
|
27
|
+
const WebRPCVersion = 'v1';
|
|
28
28
|
|
|
29
29
|
// Schema version of your RIDL schema
|
|
30
|
-
const WebRPCSchemaVersion =
|
|
30
|
+
const WebRPCSchemaVersion = 'v0.4.0';
|
|
31
31
|
|
|
32
32
|
// Schema hash generated from your RIDL schema
|
|
33
|
-
const WebRPCSchemaHash =
|
|
33
|
+
const WebRPCSchemaHash = 'a29651d1d5f63268e8d03b51e46557e0632c144d';
|
|
34
34
|
|
|
35
35
|
//
|
|
36
36
|
// Types
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/guard",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "guard sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/guard",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"ethers": "^5.7.2",
|
|
13
|
-
"@0xsequence/core": "1.1.
|
|
14
|
-
"@0xsequence/signhub": "1.1.
|
|
13
|
+
"@0xsequence/core": "1.1.2",
|
|
14
|
+
"@0xsequence/signhub": "1.1.2"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"src",
|
package/src/guard.gen.ts
CHANGED
|
@@ -6,19 +6,18 @@
|
|
|
6
6
|
// webrpc-gen -schema=guard.ridl -target=typescript -client -out=./clients/guard.gen.ts
|
|
7
7
|
|
|
8
8
|
// WebRPC description and code-gen version
|
|
9
|
-
export const WebRPCVersion =
|
|
9
|
+
export const WebRPCVersion = 'v1'
|
|
10
10
|
|
|
11
11
|
// Schema version of your RIDL schema
|
|
12
|
-
export const WebRPCSchemaVersion =
|
|
12
|
+
export const WebRPCSchemaVersion = 'v0.4.0'
|
|
13
13
|
|
|
14
14
|
// Schema hash generated from your RIDL schema
|
|
15
|
-
export const WebRPCSchemaHash =
|
|
15
|
+
export const WebRPCSchemaHash = 'a29651d1d5f63268e8d03b51e46557e0632c144d'
|
|
16
16
|
|
|
17
17
|
//
|
|
18
18
|
// Types
|
|
19
19
|
//
|
|
20
20
|
|
|
21
|
-
|
|
22
21
|
export interface Version {
|
|
23
22
|
webrpcVersion: string
|
|
24
23
|
schemaVersion: string
|
|
@@ -60,37 +59,34 @@ export interface Guard {
|
|
|
60
59
|
signWith(args: SignWithArgs, headers?: object): Promise<SignWithReturn>
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
export interface PingArgs {
|
|
64
|
-
}
|
|
62
|
+
export interface PingArgs {}
|
|
65
63
|
|
|
66
64
|
export interface PingReturn {
|
|
67
|
-
status: boolean
|
|
68
|
-
}
|
|
69
|
-
export interface VersionArgs {
|
|
65
|
+
status: boolean
|
|
70
66
|
}
|
|
67
|
+
export interface VersionArgs {}
|
|
71
68
|
|
|
72
69
|
export interface VersionReturn {
|
|
73
|
-
version: Version
|
|
74
|
-
}
|
|
75
|
-
export interface RuntimeStatusArgs {
|
|
70
|
+
version: Version
|
|
76
71
|
}
|
|
72
|
+
export interface RuntimeStatusArgs {}
|
|
77
73
|
|
|
78
74
|
export interface RuntimeStatusReturn {
|
|
79
|
-
status: RuntimeStatus
|
|
75
|
+
status: RuntimeStatus
|
|
80
76
|
}
|
|
81
77
|
export interface GetSignerConfigArgs {
|
|
82
78
|
signer: string
|
|
83
79
|
}
|
|
84
80
|
|
|
85
81
|
export interface GetSignerConfigReturn {
|
|
86
|
-
signerConfig: WalletConfig
|
|
82
|
+
signerConfig: WalletConfig
|
|
87
83
|
}
|
|
88
84
|
export interface SignArgs {
|
|
89
85
|
request: SignRequest
|
|
90
86
|
}
|
|
91
87
|
|
|
92
88
|
export interface SignReturn {
|
|
93
|
-
sig: string
|
|
89
|
+
sig: string
|
|
94
90
|
}
|
|
95
91
|
export interface SignWithArgs {
|
|
96
92
|
signer: string
|
|
@@ -98,11 +94,9 @@ export interface SignWithArgs {
|
|
|
98
94
|
}
|
|
99
95
|
|
|
100
96
|
export interface SignWithReturn {
|
|
101
|
-
sig: string
|
|
97
|
+
sig: string
|
|
102
98
|
}
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
|
|
106
100
|
//
|
|
107
101
|
// Client
|
|
108
102
|
//
|
|
@@ -119,89 +113,72 @@ export class Guard implements Guard {
|
|
|
119
113
|
private url(name: string): string {
|
|
120
114
|
return this.hostname + this.path + name
|
|
121
115
|
}
|
|
122
|
-
|
|
116
|
+
|
|
123
117
|
ping = (headers?: object): Promise<PingReturn> => {
|
|
124
|
-
return this.fetch(
|
|
125
|
-
this.url('Ping'),
|
|
126
|
-
createHTTPRequest({}, headers)
|
|
127
|
-
).then((res) => {
|
|
118
|
+
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
|
|
128
119
|
return buildResponse(res).then(_data => {
|
|
129
120
|
return {
|
|
130
|
-
status: <boolean>
|
|
121
|
+
status: <boolean>_data.status
|
|
131
122
|
}
|
|
132
123
|
})
|
|
133
124
|
})
|
|
134
125
|
}
|
|
135
|
-
|
|
126
|
+
|
|
136
127
|
version = (headers?: object): Promise<VersionReturn> => {
|
|
137
|
-
return this.fetch(
|
|
138
|
-
this.url('Version'),
|
|
139
|
-
createHTTPRequest({}, headers)
|
|
140
|
-
).then((res) => {
|
|
128
|
+
return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
|
|
141
129
|
return buildResponse(res).then(_data => {
|
|
142
130
|
return {
|
|
143
|
-
version: <Version>
|
|
131
|
+
version: <Version>_data.version
|
|
144
132
|
}
|
|
145
133
|
})
|
|
146
134
|
})
|
|
147
135
|
}
|
|
148
|
-
|
|
136
|
+
|
|
149
137
|
runtimeStatus = (headers?: object): Promise<RuntimeStatusReturn> => {
|
|
150
|
-
return this.fetch(
|
|
151
|
-
this.url('RuntimeStatus'),
|
|
152
|
-
createHTTPRequest({}, headers)
|
|
153
|
-
).then((res) => {
|
|
138
|
+
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
|
|
154
139
|
return buildResponse(res).then(_data => {
|
|
155
140
|
return {
|
|
156
|
-
status: <RuntimeStatus>
|
|
141
|
+
status: <RuntimeStatus>_data.status
|
|
157
142
|
}
|
|
158
143
|
})
|
|
159
144
|
})
|
|
160
145
|
}
|
|
161
|
-
|
|
146
|
+
|
|
162
147
|
getSignerConfig = (args: GetSignerConfigArgs, headers?: object): Promise<GetSignerConfigReturn> => {
|
|
163
|
-
return this.fetch(
|
|
164
|
-
this.url('GetSignerConfig'),
|
|
165
|
-
createHTTPRequest(args, headers)).then((res) => {
|
|
148
|
+
return this.fetch(this.url('GetSignerConfig'), createHTTPRequest(args, headers)).then(res => {
|
|
166
149
|
return buildResponse(res).then(_data => {
|
|
167
150
|
return {
|
|
168
|
-
signerConfig: <WalletConfig>
|
|
151
|
+
signerConfig: <WalletConfig>_data.signerConfig
|
|
169
152
|
}
|
|
170
153
|
})
|
|
171
154
|
})
|
|
172
155
|
}
|
|
173
|
-
|
|
156
|
+
|
|
174
157
|
sign = (args: SignArgs, headers?: object): Promise<SignReturn> => {
|
|
175
|
-
return this.fetch(
|
|
176
|
-
this.url('Sign'),
|
|
177
|
-
createHTTPRequest(args, headers)).then((res) => {
|
|
158
|
+
return this.fetch(this.url('Sign'), createHTTPRequest(args, headers)).then(res => {
|
|
178
159
|
return buildResponse(res).then(_data => {
|
|
179
160
|
return {
|
|
180
|
-
sig: <string>
|
|
161
|
+
sig: <string>_data.sig
|
|
181
162
|
}
|
|
182
163
|
})
|
|
183
164
|
})
|
|
184
165
|
}
|
|
185
|
-
|
|
166
|
+
|
|
186
167
|
signWith = (args: SignWithArgs, headers?: object): Promise<SignWithReturn> => {
|
|
187
|
-
return this.fetch(
|
|
188
|
-
this.url('SignWith'),
|
|
189
|
-
createHTTPRequest(args, headers)).then((res) => {
|
|
168
|
+
return this.fetch(this.url('SignWith'), createHTTPRequest(args, headers)).then(res => {
|
|
190
169
|
return buildResponse(res).then(_data => {
|
|
191
170
|
return {
|
|
192
|
-
sig: <string>
|
|
171
|
+
sig: <string>_data.sig
|
|
193
172
|
}
|
|
194
173
|
})
|
|
195
174
|
})
|
|
196
175
|
}
|
|
197
|
-
|
|
198
176
|
}
|
|
199
177
|
|
|
200
|
-
|
|
201
178
|
export interface WebRPCError extends Error {
|
|
202
179
|
code: string
|
|
203
180
|
msg: string
|
|
204
|
-
|
|
181
|
+
status: number
|
|
205
182
|
}
|
|
206
183
|
|
|
207
184
|
const createHTTPRequest = (body: object = {}, headers: object = {}): object => {
|
|
@@ -217,7 +194,7 @@ const buildResponse = (res: Response): Promise<any> => {
|
|
|
217
194
|
let data
|
|
218
195
|
try {
|
|
219
196
|
data = JSON.parse(text)
|
|
220
|
-
} catch(err) {
|
|
197
|
+
} catch (err) {
|
|
221
198
|
throw { code: 'unknown', msg: `expecting JSON, got: ${text}`, status: res.status } as WebRPCError
|
|
222
199
|
}
|
|
223
200
|
if (!res.ok) {
|
package/src/signer.ts
CHANGED
|
@@ -17,7 +17,11 @@ export class GuardSigner implements signers.SapientSigner {
|
|
|
17
17
|
}
|
|
18
18
|
> = new Map()
|
|
19
19
|
|
|
20
|
-
constructor(
|
|
20
|
+
constructor(
|
|
21
|
+
public readonly address: string,
|
|
22
|
+
public readonly url: string,
|
|
23
|
+
public readonly appendSuffix: boolean = false
|
|
24
|
+
) {
|
|
21
25
|
this.guard = new Guard(url, fetch)
|
|
22
26
|
}
|
|
23
27
|
|