Skip to content

Commit 95f1bd5

Browse files
committed
Merge branch 'v2' of github.com:0xsequence/sequence.js into v2
2 parents 98ae6d0 + b3d899b commit 95f1bd5

6 files changed

Lines changed: 1268 additions & 1042 deletions

File tree

packages/account/tests/signer.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,17 @@ describe('Account signer', () => {
226226

227227
beforeEach(async () => {
228228
class LocalRelayerWithFee extends LocalRelayer {
229+
public feeOptions: FeeOption[]
230+
public quote: FeeQuote
231+
229232
constructor(
230233
options: LocalRelayerOptions | ethers.Signer,
231-
public feeOptions: FeeOption[],
232-
public quote: FeeQuote
234+
feeOptions: FeeOption[],
235+
quote: FeeQuote
233236
) {
234237
super(options)
238+
this.feeOptions = feeOptions
239+
this.quote = quote
235240
}
236241

237242
async getFeeOptions(

packages/guard/src/guard.gen.ts

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/* eslint-disable */
2-
// sequence-guard v0.4.0 776b307c2145ac7a994eec63240acae042c96067
2+
// sequence-guard v0.5.0 910e01c32ffb24b42386d4ca6be119b0acc55c5f
33
// --
44
// Code generated by webrpc-gen@v0.25.3 with typescript generator. DO NOT EDIT.
55
//
66
// webrpc-gen -schema=guard.ridl -target=typescript -client -out=./clients/guard.gen.ts
77

88
export const WebrpcHeader = 'Webrpc'
99

10-
export const WebrpcHeaderValue = 'webrpc@v0.25.3;gen-typescript@v0.17.0;sequence-guard@v0.4.0'
10+
export const WebrpcHeaderValue = 'webrpc@v0.25.3;gen-typescript@v0.17.0;sequence-guard@v0.5.0'
1111

1212
// WebRPC description and code-gen version
1313
export const WebRPCVersion = 'v1'
1414

1515
// Schema version of your RIDL schema
16-
export const WebRPCSchemaVersion = 'v0.4.0'
16+
export const WebRPCSchemaVersion = 'v0.5.0'
1717

1818
// Schema hash generated from your RIDL schema
19-
export const WebRPCSchemaHash = '776b307c2145ac7a994eec63240acae042c96067'
19+
export const WebRPCSchemaHash = '910e01c32ffb24b42386d4ca6be119b0acc55c5f'
2020

2121
type WebrpcGenVersions = {
2222
webrpcGenVersion: string
@@ -70,6 +70,20 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
7070
// Types
7171
//
7272

73+
export enum PayloadType {
74+
Calls = 'Calls',
75+
Message = 'Message',
76+
ConfigUpdate = 'ConfigUpdate',
77+
SessionImplicitAuthorize = 'SessionImplicitAuthorize'
78+
}
79+
80+
export enum SignatureType {
81+
Hash = 'Hash',
82+
Sapient = 'Sapient',
83+
EthSign = 'EthSign',
84+
Erc1271 = 'Erc1271'
85+
}
86+
7387
export interface Version {
7488
webrpcVersion: string
7589
schemaVersion: string
@@ -99,26 +113,39 @@ export interface WalletSigner {
99113
export interface SignRequest {
100114
chainId: number
101115
msg: string
102-
auxData: string
116+
auxData?: string
117+
wallet?: string
118+
payloadType?: PayloadType
119+
payloadData?: string
120+
signatures?: Array<Signature>
103121
}
104122

105123
export interface OwnershipProof {
106124
wallet: string
107125
timestamp: number
108126
signer: string
109127
signature: string
128+
chainId: number
110129
}
111130

112131
export interface AuthToken {
113132
id: string
114133
token: string
134+
resetAuth?: boolean
115135
}
116136

117137
export interface RecoveryCode {
118138
code: string
119139
used: boolean
120140
}
121141

142+
export interface Signature {
143+
address: string
144+
type: SignatureType
145+
imageHash?: string
146+
data: string
147+
}
148+
122149
export interface Guard {
123150
ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>
124151
version(headers?: object, signal?: AbortSignal): Promise<VersionReturn>
@@ -242,18 +269,21 @@ export interface SetPINArgs {
242269
pin: string
243270
timestamp: number
244271
signature: string
272+
chainId: number
245273
}
246274

247275
export interface SetPINReturn {}
248276
export interface ResetPINArgs {
249277
timestamp: number
250278
signature: string
279+
chainId: number
251280
}
252281

253282
export interface ResetPINReturn {}
254283
export interface CreateTOTPArgs {
255284
timestamp: number
256285
signature: string
286+
chainId: number
257287
}
258288

259289
export interface CreateTOTPReturn {
@@ -269,6 +299,7 @@ export interface CommitTOTPReturn {
269299
export interface ResetTOTPArgs {
270300
timestamp: number
271301
signature: string
302+
chainId: number
272303
}
273304

274305
export interface ResetTOTPReturn {}
@@ -281,6 +312,7 @@ export interface Reset2FAReturn {}
281312
export interface RecoveryCodesArgs {
282313
timestamp: number
283314
signature: string
315+
chainId: number
284316
}
285317

286318
export interface RecoveryCodesReturn {
@@ -289,6 +321,7 @@ export interface RecoveryCodesReturn {
289321
export interface ResetRecoveryCodesArgs {
290322
timestamp: number
291323
signature: string
324+
chainId: number
292325
}
293326

294327
export interface ResetRecoveryCodesReturn {
@@ -931,6 +964,32 @@ export class NotFoundError extends WebrpcError {
931964
}
932965
}
933966

967+
export class RequiresTOTPError extends WebrpcError {
968+
constructor(
969+
name: string = 'RequiresTOTP',
970+
code: number = 6600,
971+
message: string = `TOTP is required`,
972+
status: number = 0,
973+
cause?: string
974+
) {
975+
super(name, code, message, status, cause)
976+
Object.setPrototypeOf(this, RequiresTOTPError.prototype)
977+
}
978+
}
979+
980+
export class RequiresPINError extends WebrpcError {
981+
constructor(
982+
name: string = 'RequiresPIN',
983+
code: number = 6601,
984+
message: string = `PIN is required`,
985+
status: number = 0,
986+
cause?: string
987+
) {
988+
super(name, code, message, status, cause)
989+
Object.setPrototypeOf(this, RequiresPINError.prototype)
990+
}
991+
}
992+
934993
export enum errors {
935994
WebrpcEndpoint = 'WebrpcEndpoint',
936995
WebrpcRequestFailed = 'WebrpcRequestFailed',
@@ -955,7 +1014,9 @@ export enum errors {
9551014
Unavailable = 'Unavailable',
9561015
QueryFailed = 'QueryFailed',
9571016
ValidationFailed = 'ValidationFailed',
958-
NotFound = 'NotFound'
1017+
NotFound = 'NotFound',
1018+
RequiresTOTP = 'RequiresTOTP',
1019+
RequiresPIN = 'RequiresPIN'
9591020
}
9601021

9611022
export enum WebrpcErrorCodes {
@@ -982,7 +1043,9 @@ export enum WebrpcErrorCodes {
9821043
Unavailable = 2002,
9831044
QueryFailed = 2003,
9841045
ValidationFailed = 2004,
985-
NotFound = 3000
1046+
NotFound = 3000,
1047+
RequiresTOTP = 6600,
1048+
RequiresPIN = 6601
9861049
}
9871050

9881051
export const webrpcErrorByCode: { [code: number]: any } = {
@@ -1009,7 +1072,9 @@ export const webrpcErrorByCode: { [code: number]: any } = {
10091072
[2002]: UnavailableError,
10101073
[2003]: QueryFailedError,
10111074
[2004]: ValidationFailedError,
1012-
[3000]: NotFoundError
1075+
[3000]: NotFoundError,
1076+
[6600]: RequiresTOTPError,
1077+
[6601]: RequiresPINError
10131078
}
10141079

10151080
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>

packages/guard/src/signer.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ export class GuardSigner implements signers.SapientSigner {
9191
wallet: signedProof.walletAddress,
9292
timestamp: signedProof.timestamp.getTime(),
9393
signer: signedProof.signerAddress,
94-
signature: signedProof.signature
94+
signature: signedProof.signature,
95+
chainId: 1
9596
}
9697
})
9798
}
@@ -104,12 +105,12 @@ export class GuardSigner implements signers.SapientSigner {
104105

105106
if (pin === undefined) {
106107
await this.guard.resetPIN(
107-
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
108+
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
108109
{ Authorization: `BEARER ${proof.jwt}` }
109110
)
110111
} else {
111112
await this.guard.setPIN(
112-
{ pin, timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
113+
{ pin, timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
113114
{ Authorization: `BEARER ${proof.jwt}` }
114115
)
115116
}
@@ -123,7 +124,7 @@ export class GuardSigner implements signers.SapientSigner {
123124
const signedProof = await signAuthUpdateProof(proof)
124125

125126
const { uri } = await this.guard.createTOTP(
126-
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
127+
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
127128
{ Authorization: `BEARER ${proof.jwt}` }
128129
)
129130

@@ -139,7 +140,7 @@ export class GuardSigner implements signers.SapientSigner {
139140
const signedProof = await signAuthUpdateProof(proof)
140141

141142
await this.guard.resetTOTP(
142-
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
143+
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
143144
{ Authorization: `BEARER ${proof.jwt}` }
144145
)
145146
}
@@ -156,7 +157,8 @@ export class GuardSigner implements signers.SapientSigner {
156157
wallet: signedProof.walletAddress,
157158
timestamp: signedProof.timestamp.getTime(),
158159
signer: signedProof.signerAddress,
159-
signature: signedProof.signature
160+
signature: signedProof.signature,
161+
chainId: 1
160162
}
161163
})
162164
}
@@ -166,7 +168,7 @@ export class GuardSigner implements signers.SapientSigner {
166168
const signedProof = await signAuthUpdateProof(proof)
167169

168170
const { codes } = await this.guard.recoveryCodes(
169-
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
171+
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
170172
{ Authorization: `BEARER ${proof.jwt}` }
171173
)
172174

@@ -177,7 +179,7 @@ export class GuardSigner implements signers.SapientSigner {
177179
const signedProof = await signAuthUpdateProof(proof)
178180

179181
const { codes } = await this.guard.resetRecoveryCodes(
180-
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature },
182+
{ timestamp: signedProof.timestamp.getTime(), signature: signedProof.signature, chainId: 1 },
181183
{ Authorization: `BEARER ${proof.jwt}` }
182184
)
183185

packages/marketplace/src/marketplace.gen.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable */
2-
// marketplace-api v0-25.12.1+61b56ff ec2402a5d97f7a444807ac40e894721991bdb228
2+
// marketplace-api v0-25.12.1+61b56ff 695923688f38cbb56ca3bab78e75d9a0f48c10e2
33
// --
44
// Code generated by webrpc-gen@v0.31.2 with github.com/webrpc/gen-typescript@v0.19.0 generator. DO NOT EDIT.
55
//
@@ -16,7 +16,7 @@ export const WebRPCVersion = 'v1'
1616
export const WebRPCSchemaVersion = 'v0-25.12.1+61b56ff'
1717

1818
// Schema hash generated from your RIDL schema
19-
export const WebRPCSchemaHash = 'ec2402a5d97f7a444807ac40e894721991bdb228'
19+
export const WebRPCSchemaHash = '695923688f38cbb56ca3bab78e75d9a0f48c10e2'
2020

2121
type WebrpcGenVersions = {
2222
webrpcGenVersion: string
@@ -535,6 +535,11 @@ export interface Domain {
535535
verifyingContract: string
536536
}
537537

538+
export interface GenerateBuySellTransactionResponse {
539+
steps: Array<Step>
540+
canBeUsedWithTrails: boolean
541+
}
542+
538543
export interface CheckoutOptionsMarketplaceOrder {
539544
contractAddress: string
540545
orderId: string
@@ -1267,9 +1272,11 @@ export interface GenerateBuyTransactionArgs {
12671272
ordersData: Array<OrderData>
12681273
additionalFees: Array<AdditionalFee>
12691274
walletType?: WalletKind
1275+
useWithTrails: boolean
12701276
}
12711277

12721278
export interface GenerateBuyTransactionReturn {
1279+
resp: GenerateBuySellTransactionResponse
12731280
steps: Array<Step>
12741281
}
12751282
export interface GenerateSellTransactionArgs {
@@ -1280,9 +1287,11 @@ export interface GenerateSellTransactionArgs {
12801287
ordersData: Array<OrderData>
12811288
additionalFees: Array<AdditionalFee>
12821289
walletType?: WalletKind
1290+
useWithTrails: boolean
12831291
}
12841292

12851293
export interface GenerateSellTransactionReturn {
1294+
resp: GenerateBuySellTransactionResponse
12861295
steps: Array<Step>
12871296
}
12881297
export interface GenerateListingTransactionArgs {
@@ -2179,6 +2188,7 @@ export class Marketplace implements Marketplace {
21792188
res => {
21802189
return buildResponse(res).then(_data => {
21812190
return {
2191+
resp: <GenerateBuySellTransactionResponse>_data.resp,
21822192
steps: <Array<Step>>_data.steps
21832193
}
21842194
})
@@ -2198,6 +2208,7 @@ export class Marketplace implements Marketplace {
21982208
res => {
21992209
return buildResponse(res).then(_data => {
22002210
return {
2211+
resp: <GenerateBuySellTransactionResponse>_data.resp,
22012212
steps: <Array<Step>>_data.steps
22022213
}
22032214
})

0 commit comments

Comments
 (0)