Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prettier": "^3.8.3",
"rimraf": "^6.1.3",
"syncpack": "^14.3.1",
"turbo": "^2.9.8",
"turbo": "^2.9.14",
"typescript": "^6.0.3"
},
"pnpm": {
Expand Down
6 changes: 6 additions & 0 deletions packages/services/api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @0xsequence/api

## 3.0.11

### Patch Changes

- Fix for relayer sponsored fees

## 3.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/services/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xsequence/api",
"version": "3.0.10",
"version": "3.0.11",
"description": "api sub-package for Sequence",
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/services/api",
"author": "Sequence Platforms ULC",
Expand Down
6 changes: 6 additions & 0 deletions packages/services/builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @0xsequence/builder

## 3.0.11

### Patch Changes

- Fix for relayer sponsored fees

## 3.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/services/builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xsequence/builder",
"version": "3.0.10",
"version": "3.0.11",
"description": "builder sub-package for Sequence",
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/services/builder",
"author": "Sequence Platforms ULC",
Expand Down
6 changes: 6 additions & 0 deletions packages/services/guard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @0xsequence/guard

## 3.0.11

### Patch Changes

- Fix for relayer sponsored fees

## 3.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/services/guard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xsequence/guard",
"version": "3.0.10",
"version": "3.0.11",
"description": "guard sub-package for Sequence",
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/services/guard",
"author": "Sequence Platforms ULC",
Expand Down
6 changes: 6 additions & 0 deletions packages/services/identity-instrument/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @0xsequence/identity-instrument

## 3.0.11

### Patch Changes

- Fix for relayer sponsored fees

## 3.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/services/identity-instrument/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xsequence/identity-instrument",
"version": "3.0.10",
"version": "3.0.11",
"license": "Apache-2.0",
"type": "module",
"publishConfig": {
Expand Down
6 changes: 6 additions & 0 deletions packages/services/indexer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @0xsequence/indexer

## 3.0.11

### Patch Changes

- Fix for relayer sponsored fees

## 3.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/services/indexer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xsequence/indexer",
"version": "3.0.10",
"version": "3.0.11",
"description": "indexer sub-package for Sequence",
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/services/indexer",
"author": "Sequence Platforms ULC",
Expand Down
6 changes: 6 additions & 0 deletions packages/services/marketplace/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @0xsequence/marketplace

## 3.0.11

### Patch Changes

- Fix for relayer sponsored fees

## 3.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/services/marketplace/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xsequence/marketplace",
"version": "3.0.10",
"version": "3.0.11",
"description": "marketplace sub-package for Sequence",
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/services/marketplace",
"author": "Sequence Platforms ULC",
Expand Down
6 changes: 6 additions & 0 deletions packages/services/metadata/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @0xsequence/metadata

## 3.0.11

### Patch Changes

- Fix for relayer sponsored fees

## 3.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/services/metadata/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xsequence/metadata",
"version": "3.0.10",
"version": "3.0.11",
"publishConfig": {
"access": "public"
},
Expand Down
26 changes: 26 additions & 0 deletions packages/services/relayer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# @0xsequence/relayer

## 3.1.0

### Minor Changes

- 55121af: Surface explicit sponsorship signal on `feeOptions` and an error marker on
`feeOptions` / `feeTokens`.
- `RpcRelayer.feeOptions` now returns `sponsored: boolean`, forwarded from the
server's `FeeOptionsReturn.sponsored`. The `Relayer` interface and all
bundled implementations (`RpcRelayer`, `SequenceRelayer`, `LocalRelayer`,
`EIP6963Relayer`, `PkRelayer`) carry the new field.
- When `feeOptions` swallows a transport / server error it now returns
`{ options: [], sponsored: false, failed: true }` (was `{ options: [] }`).
- When `feeTokens` swallows an error it now returns
`{ isFeeRequired: false, failed: true }` (was `{ isFeeRequired: false }`).

These changes are additive — existing consumers that ignore the new fields are
unaffected. Consumers that classified sponsorship by "no fee option attached"
should migrate to `sponsored === true` to distinguish a real subsidy from a
swallowed `/FeeOptions` error.

### Patch Changes

- Fix for relayer sponsored fees
- Updated dependencies
- @0xsequence/wallet-primitives@3.0.11

## 3.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/services/relayer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xsequence/relayer",
"version": "3.0.10",
"version": "3.1.0",
"type": "module",
"publishConfig": {
"access": "public"
Expand Down
9 changes: 7 additions & 2 deletions packages/services/relayer/src/relayer/relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ export interface Relayer {

isAvailable(wallet: Address.Address, chainId: number): Promise<boolean>

feeTokens(): Promise<{ isFeeRequired: boolean; tokens?: FeeToken[]; paymentAddress?: Address.Address }>
feeTokens(): Promise<{
isFeeRequired: boolean
tokens?: FeeToken[]
paymentAddress?: Address.Address
failed?: boolean
}>

feeOptions(
wallet: Address.Address,
chainId: number,
to: Address.Address,
calls: Payload.Call[],
data?: Hex.Hex,
): Promise<{ options: FeeOption[]; quote?: FeeQuote }>
): Promise<{ options: FeeOption[]; quote?: FeeQuote; sponsored: boolean; failed?: boolean }>

relay(to: Address.Address, data: Hex.Hex, chainId: number, quote?: FeeQuote): Promise<{ opHash: Hex.Hex }>

Expand Down
15 changes: 10 additions & 5 deletions packages/services/relayer/src/relayer/rpc-relayer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ export class RpcRelayer implements Relayer {
return Promise.resolve(this.chainId === chainId)
}

async feeTokens(): Promise<{ isFeeRequired: boolean; tokens?: RpcFeeToken[]; paymentAddress?: Address.Address }> {
async feeTokens(): Promise<{
isFeeRequired: boolean
tokens?: RpcFeeToken[]
paymentAddress?: Address.Address
failed?: boolean
}> {
try {
const { isFeeRequired, tokens, paymentAddress } = await this.client.feeTokens()
if (isFeeRequired) {
Expand All @@ -140,7 +145,7 @@ export class RpcRelayer implements Relayer {
}
} catch (e) {
console.warn('RpcRelayer.feeTokens failed:', e)
return { isFeeRequired: false }
return { isFeeRequired: false, failed: true }
}
}

Expand All @@ -150,7 +155,7 @@ export class RpcRelayer implements Relayer {
to: Address.Address,
calls: Payload.Call[],
data?: Hex.Hex,
): Promise<{ options: FeeOption[]; quote?: FeeQuote }> {
): Promise<{ options: FeeOption[]; quote?: FeeQuote; sponsored: boolean; failed?: boolean }> {
// IMPORTANT:
// The relayer FeeOptions endpoint simulates `eth_call(to, data)`.
// Callers that already built a wallet transaction should pass its `to` and `data`.
Expand Down Expand Up @@ -182,10 +187,10 @@ export class RpcRelayer implements Relayer {
gasLimit: option.gasLimit,
}))

return { options, quote }
return { options, quote, sponsored: result.sponsored }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since sponsored is a required boolean in the Relayer.feeOptions interface, we should ensure it defaults to false if result.sponsored is undefined (e.g., if the server response does not include it or if it is optional in the client's type definition).

Suggested change
return { options, quote, sponsored: result.sponsored }
return { options, quote, sponsored: result.sponsored ?? false }

} catch (e) {
console.warn('RpcRelayer.feeOptions failed:', e)
return { options: [] }
return { options: [], sponsored: false, failed: true }
}
}

Expand Down
9 changes: 7 additions & 2 deletions packages/services/relayer/src/relayer/standard/eip6963.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export class EIP6963Relayer implements Relayer {
return this.relayer.isAvailable(wallet, chainId)
}

feeTokens(): Promise<{ isFeeRequired: boolean; tokens?: FeeToken[]; paymentAddress?: Address.Address }> {
feeTokens(): Promise<{
isFeeRequired: boolean
tokens?: FeeToken[]
paymentAddress?: Address.Address
failed?: boolean
}> {
return this.relayer.feeTokens()
}

Expand All @@ -32,7 +37,7 @@ export class EIP6963Relayer implements Relayer {
chainId: number,
to: Address.Address,
calls: Payload.Call[],
): Promise<{ options: FeeOption[]; quote?: FeeQuote }> {
): Promise<{ options: FeeOption[]; quote?: FeeQuote; sponsored: boolean; failed?: boolean }> {
return this.relayer.feeOptions(wallet, chainId, to, calls)
}

Expand Down
11 changes: 8 additions & 3 deletions packages/services/relayer/src/relayer/standard/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ export class LocalRelayer implements Relayer {
return new LocalRelayer(new EIP1193ProviderAdapter(provider))
}

feeTokens(): Promise<{ isFeeRequired: boolean; tokens?: FeeToken[]; paymentAddress?: Address.Address }> {
feeTokens(): Promise<{
isFeeRequired: boolean
tokens?: FeeToken[]
paymentAddress?: Address.Address
failed?: boolean
}> {
return Promise.resolve({
isFeeRequired: false,
})
Expand All @@ -67,8 +72,8 @@ export class LocalRelayer implements Relayer {
_chainId: number,
_to: Address.Address,
_calls: Payload.Call[],
): Promise<{ options: FeeOption[]; quote?: FeeQuote }> {
return Promise.resolve({ options: [] })
): Promise<{ options: FeeOption[]; quote?: FeeQuote; sponsored: boolean; failed?: boolean }> {
return Promise.resolve({ options: [], sponsored: false })
}

async relay(
Expand Down
9 changes: 7 additions & 2 deletions packages/services/relayer/src/relayer/standard/pk-relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ export class PkRelayer implements Relayer {
return providerChainId === chainId
}

feeTokens(): Promise<{ isFeeRequired: boolean; tokens?: FeeToken[]; paymentAddress?: Address.Address }> {
feeTokens(): Promise<{
isFeeRequired: boolean
tokens?: FeeToken[]
paymentAddress?: Address.Address
failed?: boolean
}> {
return this.relayer.feeTokens()
}

Expand All @@ -116,7 +121,7 @@ export class PkRelayer implements Relayer {
chainId: number,
to: Address.Address,
calls: Payload.Call[],
): Promise<{ options: FeeOption[]; quote?: FeeQuote }> {
): Promise<{ options: FeeOption[]; quote?: FeeQuote; sponsored: boolean; failed?: boolean }> {
return this.relayer.feeOptions(wallet, chainId, to, calls)
}

Expand Down
12 changes: 9 additions & 3 deletions packages/services/relayer/src/relayer/standard/sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export class SequenceRelayer implements Relayer {
return true
}

async feeTokens(): Promise<{ isFeeRequired: boolean; tokens?: FeeToken[]; paymentAddress?: Address.Address }> {
async feeTokens(): Promise<{
isFeeRequired: boolean
tokens?: FeeToken[]
paymentAddress?: Address.Address
failed?: boolean
}> {
const { isFeeRequired, tokens, paymentAddress } = await this.service.feeTokens()
if (isFeeRequired) {
Address.assert(paymentAddress)
Expand All @@ -39,17 +44,18 @@ export class SequenceRelayer implements Relayer {
to: Address.Address,
calls: Payload.Call[],
transactionData?: Hex.Hex,
): Promise<{ options: FeeOption[]; quote?: FeeQuote }> {
): Promise<{ options: FeeOption[]; quote?: FeeQuote; sponsored: boolean; failed?: boolean }> {
const execute = AbiFunction.from('function execute(bytes calldata _payload, bytes calldata _signature)')
const payload = Payload.encode({ type: 'call', space: 0n, nonce: 0n, calls }, to)
const signature = '0x0001' // TODO: use a stub signature
const data = transactionData ?? AbiFunction.encodeData(execute, [Bytes.toHex(payload), signature])

const { options, quote } = await this.service.feeOptions({ wallet, to, data })
const { options, quote, sponsored } = await this.service.feeOptions({ wallet, to, data })

return {
options,
quote: quote ? { _tag: 'FeeQuote', _quote: quote } : undefined,
sponsored,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since sponsored is a required boolean in the Relayer.feeOptions interface, we should ensure it defaults to false if sponsored returned from this.service.feeOptions is undefined.

Suggested change
sponsored,
sponsored: sponsored ?? false,

}
}

Expand Down
Loading