Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@0xsequence/relayer

Package Overview
Dependencies
Maintainers
4
Versions
520
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xsequence/relayer - npm Package Compare versions

Comparing version 0.22.2 to 0.23.0

15

CHANGELOG.md
# @0xsequence/relayer
## 0.23.0
### Minor Changes
- - relayer: offer variety of gas fee options from the relayer service"
### Patch Changes
- Updated dependencies [undefined]
- @0xsequence/abi@0.23.0
- @0xsequence/chaind@0.23.0
- @0xsequence/config@0.23.0
- @0xsequence/transactions@0.23.0
- @0xsequence/utils@0.23.0
## 0.22.2

@@ -4,0 +19,0 @@

98

dist/0xsequence-relayer.cjs.dev.js

@@ -207,3 +207,3 @@ 'use strict';

async gasRefundOptions(_config, _context, ..._transactions) {
return [[]];
return [];
}

@@ -232,3 +232,3 @@

/* eslint-disable */
// relayer v0.3.0 a91267ba653a2d505e8e7c621cd95c9c2c34437a
// relayer v0.3.0 9438009246584134620a2a88e9587ab12b77c63f
// --

@@ -242,3 +242,3 @@ // This file has been generated by https://github.com/webrpc/webrpc using gen/typescript

const WebRPCSchemaHash = "a91267ba653a2d505e8e7c621cd95c9c2c34437a"; //
const WebRPCSchemaHash = "9438009246584134620a2a88e9587ab12b77c63f"; //
// Types

@@ -260,2 +260,14 @@ //

let ContractType;
(function (ContractType) {
ContractType["UNKNOWN"] = "UNKNOWN";
ContractType["ERC20_TOKEN"] = "ERC20_TOKEN";
ContractType["ERC721_TOKEN"] = "ERC721_TOKEN";
ContractType["ERC1155_TOKEN"] = "ERC1155_TOKEN";
ContractType["META_ERC20_WRAPPER"] = "META_ERC20_WRAPPER";
ContractType["NIFTYSWAP"] = "NIFTYSWAP";
ContractType["BRIDGE"] = "BRIDGE";
})(ContractType || (ContractType = {}));
//

@@ -362,7 +374,7 @@ // Client

this.getMetaTxnNetworkFeeOptions = (args, headers) => {
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHTTPRequest(args, headers)).then(res => {
this.updateMetaTxnGasLimits = (args, headers) => {
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
return buildResponse(res).then(_data => {
return {
options: _data.options
payload: _data.payload
};

@@ -373,7 +385,8 @@ });

this.updateMetaTxnGasLimits = (args, headers) => {
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
this.feeTokens = headers => {
return this.fetch(this.url('FeeTokens'), createHTTPRequest({}, headers)).then(res => {
return buildResponse(res).then(_data => {
return {
payload: _data.payload
isFeeRequired: _data.isFeeRequired,
tokens: _data.tokens
};

@@ -384,2 +397,12 @@ });

this.getMetaTxnNetworkFeeOptions = (args, headers) => {
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHTTPRequest(args, headers)).then(res => {
return buildResponse(res).then(_data => {
return {
options: _data.options
};
});
});
};
this.pushMetaTxn = (args, headers) => {

@@ -454,2 +477,3 @@ return this.fetch(this.url('PushMetaTxn'), createHTTPRequest(args, headers)).then(res => {

get ETHTxnStatus () { return ETHTxnStatus; },
get ContractType () { return ContractType; },
RelayerService: RelayerService

@@ -520,40 +544,30 @@ });

async gasRefundOptions(config$1, context, ...transactions$1) {
// chaind only supports refunds on a single token
// TODO: Add compatiblity for different refund options
const tokenFee = await this.service.tokenFee();
utils.logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${JSON.stringify(tokenFee)}`); // No gas refund required
// NOTE/TODO: for a given `service` the feeTokens will not change between execution, so we should memoize this value
// for a short-period of time, perhaps for 1 day or in memory. Perhaps one day we can make this happen automatically
// with http cache response for this endpoint and service-worker.. lots of approaches
const feeTokens = await this.service.feeTokens();
if (!tokenFee.isFee || tokenFee.fee === ethers.ethers.constants.AddressZero) {
return [[]];
}
if (feeTokens.isFeeRequired) {
const symbols = feeTokens.tokens.map(token => token.symbol).join(', ');
utils.logger.info(`[rpc-relayer/gasRefundOptions] relayer fees are required, accepted tokens are ${symbols}`);
const addr = config.addressOf(config$1, context);
const prevNonce = transactions.readSequenceNonce(...transactions$1); // Set temporal nonce to simulate meta-txn
const addr = config.addressOf(config$1, context);
const prevNonce = transactions.readSequenceNonce(...transactions$1); // Set temporal nonce to simulate meta-txn
if (prevNonce === undefined) {
transactions$1 = transactions.appendNonce(transactions$1, await this.getNonce(config$1, context));
}
if (prevNonce === undefined) {
transactions$1 = transactions.appendNonce(transactions$1, await this.getNonce(config$1, context));
}
const coder = ethers.ethers.utils.defaultAbiCoder;
const encoded = coder.encode([transactions.MetaTransactionsType], [transactions.sequenceTxAbiEncode(transactions$1)]);
const res = await this.service.getMetaTxnNetworkFeeOptions({
walletAddress: addr,
payload: encoded,
signers: config$1.signers.length
});
let decoded;
if (prevNonce === undefined) {
decoded = res.options.map(option => coder.decode([transactions.MetaTransactionsType], option)[0].map(txn => _extends({}, txn, {
to: txn.target
})));
const coder = ethers.ethers.utils.defaultAbiCoder;
const encoded = coder.encode([transactions.MetaTransactionsType], [transactions.sequenceTxAbiEncode(transactions$1)]);
const res = await this.service.getMetaTxnNetworkFeeOptions({
walletAddress: addr,
payload: encoded,
signers: config$1.signers.length
});
utils.logger.info(`[rpc-relayer/gasRefundOptions] got refund options ${JSON.stringify(res.options)}`);
return res.options;
} else {
decoded = res.options.map(option => coder.decode([transactions.MetaTransactionsType], option)[0].map(txn => _extends({}, txn, {
to: txn.target,
nonce: prevNonce
})));
utils.logger.info(`[rpc-relayer/gasRefundOptions] relayer fees are not required`);
return [];
}
utils.logger.info(`[rpc-relayer/gasRefundOptions] got refund options ${JSON.stringify(decoded)}`);
return decoded;
}

@@ -560,0 +574,0 @@

@@ -207,3 +207,3 @@ 'use strict';

async gasRefundOptions(_config, _context, ..._transactions) {
return [[]];
return [];
}

@@ -232,3 +232,3 @@

/* eslint-disable */
// relayer v0.3.0 a91267ba653a2d505e8e7c621cd95c9c2c34437a
// relayer v0.3.0 9438009246584134620a2a88e9587ab12b77c63f
// --

@@ -242,3 +242,3 @@ // This file has been generated by https://github.com/webrpc/webrpc using gen/typescript

const WebRPCSchemaHash = "a91267ba653a2d505e8e7c621cd95c9c2c34437a"; //
const WebRPCSchemaHash = "9438009246584134620a2a88e9587ab12b77c63f"; //
// Types

@@ -260,2 +260,14 @@ //

let ContractType;
(function (ContractType) {
ContractType["UNKNOWN"] = "UNKNOWN";
ContractType["ERC20_TOKEN"] = "ERC20_TOKEN";
ContractType["ERC721_TOKEN"] = "ERC721_TOKEN";
ContractType["ERC1155_TOKEN"] = "ERC1155_TOKEN";
ContractType["META_ERC20_WRAPPER"] = "META_ERC20_WRAPPER";
ContractType["NIFTYSWAP"] = "NIFTYSWAP";
ContractType["BRIDGE"] = "BRIDGE";
})(ContractType || (ContractType = {}));
//

@@ -362,7 +374,7 @@ // Client

this.getMetaTxnNetworkFeeOptions = (args, headers) => {
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHTTPRequest(args, headers)).then(res => {
this.updateMetaTxnGasLimits = (args, headers) => {
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
return buildResponse(res).then(_data => {
return {
options: _data.options
payload: _data.payload
};

@@ -373,7 +385,8 @@ });

this.updateMetaTxnGasLimits = (args, headers) => {
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
this.feeTokens = headers => {
return this.fetch(this.url('FeeTokens'), createHTTPRequest({}, headers)).then(res => {
return buildResponse(res).then(_data => {
return {
payload: _data.payload
isFeeRequired: _data.isFeeRequired,
tokens: _data.tokens
};

@@ -384,2 +397,12 @@ });

this.getMetaTxnNetworkFeeOptions = (args, headers) => {
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHTTPRequest(args, headers)).then(res => {
return buildResponse(res).then(_data => {
return {
options: _data.options
};
});
});
};
this.pushMetaTxn = (args, headers) => {

@@ -454,2 +477,3 @@ return this.fetch(this.url('PushMetaTxn'), createHTTPRequest(args, headers)).then(res => {

get ETHTxnStatus () { return ETHTxnStatus; },
get ContractType () { return ContractType; },
RelayerService: RelayerService

@@ -520,40 +544,30 @@ });

async gasRefundOptions(config$1, context, ...transactions$1) {
// chaind only supports refunds on a single token
// TODO: Add compatiblity for different refund options
const tokenFee = await this.service.tokenFee();
utils.logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${JSON.stringify(tokenFee)}`); // No gas refund required
// NOTE/TODO: for a given `service` the feeTokens will not change between execution, so we should memoize this value
// for a short-period of time, perhaps for 1 day or in memory. Perhaps one day we can make this happen automatically
// with http cache response for this endpoint and service-worker.. lots of approaches
const feeTokens = await this.service.feeTokens();
if (!tokenFee.isFee || tokenFee.fee === ethers.ethers.constants.AddressZero) {
return [[]];
}
if (feeTokens.isFeeRequired) {
const symbols = feeTokens.tokens.map(token => token.symbol).join(', ');
utils.logger.info(`[rpc-relayer/gasRefundOptions] relayer fees are required, accepted tokens are ${symbols}`);
const addr = config.addressOf(config$1, context);
const prevNonce = transactions.readSequenceNonce(...transactions$1); // Set temporal nonce to simulate meta-txn
const addr = config.addressOf(config$1, context);
const prevNonce = transactions.readSequenceNonce(...transactions$1); // Set temporal nonce to simulate meta-txn
if (prevNonce === undefined) {
transactions$1 = transactions.appendNonce(transactions$1, await this.getNonce(config$1, context));
}
if (prevNonce === undefined) {
transactions$1 = transactions.appendNonce(transactions$1, await this.getNonce(config$1, context));
}
const coder = ethers.ethers.utils.defaultAbiCoder;
const encoded = coder.encode([transactions.MetaTransactionsType], [transactions.sequenceTxAbiEncode(transactions$1)]);
const res = await this.service.getMetaTxnNetworkFeeOptions({
walletAddress: addr,
payload: encoded,
signers: config$1.signers.length
});
let decoded;
if (prevNonce === undefined) {
decoded = res.options.map(option => coder.decode([transactions.MetaTransactionsType], option)[0].map(txn => _extends({}, txn, {
to: txn.target
})));
const coder = ethers.ethers.utils.defaultAbiCoder;
const encoded = coder.encode([transactions.MetaTransactionsType], [transactions.sequenceTxAbiEncode(transactions$1)]);
const res = await this.service.getMetaTxnNetworkFeeOptions({
walletAddress: addr,
payload: encoded,
signers: config$1.signers.length
});
utils.logger.info(`[rpc-relayer/gasRefundOptions] got refund options ${JSON.stringify(res.options)}`);
return res.options;
} else {
decoded = res.options.map(option => coder.decode([transactions.MetaTransactionsType], option)[0].map(txn => _extends({}, txn, {
to: txn.target,
nonce: prevNonce
})));
utils.logger.info(`[rpc-relayer/gasRefundOptions] relayer fees are not required`);
return [];
}
utils.logger.info(`[rpc-relayer/gasRefundOptions] got refund options ${JSON.stringify(decoded)}`);
return decoded;
}

@@ -560,0 +574,0 @@

@@ -199,3 +199,3 @@ import { providers, ethers, Signer } from 'ethers';

async gasRefundOptions(_config, _context, ..._transactions) {
return [[]];
return [];
}

@@ -224,3 +224,3 @@

/* eslint-disable */
// relayer v0.3.0 a91267ba653a2d505e8e7c621cd95c9c2c34437a
// relayer v0.3.0 9438009246584134620a2a88e9587ab12b77c63f
// --

@@ -234,3 +234,3 @@ // This file has been generated by https://github.com/webrpc/webrpc using gen/typescript

const WebRPCSchemaHash = "a91267ba653a2d505e8e7c621cd95c9c2c34437a"; //
const WebRPCSchemaHash = "9438009246584134620a2a88e9587ab12b77c63f"; //
// Types

@@ -252,2 +252,14 @@ //

let ContractType;
(function (ContractType) {
ContractType["UNKNOWN"] = "UNKNOWN";
ContractType["ERC20_TOKEN"] = "ERC20_TOKEN";
ContractType["ERC721_TOKEN"] = "ERC721_TOKEN";
ContractType["ERC1155_TOKEN"] = "ERC1155_TOKEN";
ContractType["META_ERC20_WRAPPER"] = "META_ERC20_WRAPPER";
ContractType["NIFTYSWAP"] = "NIFTYSWAP";
ContractType["BRIDGE"] = "BRIDGE";
})(ContractType || (ContractType = {}));
//

@@ -354,7 +366,7 @@ // Client

this.getMetaTxnNetworkFeeOptions = (args, headers) => {
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHTTPRequest(args, headers)).then(res => {
this.updateMetaTxnGasLimits = (args, headers) => {
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
return buildResponse(res).then(_data => {
return {
options: _data.options
payload: _data.payload
};

@@ -365,7 +377,8 @@ });

this.updateMetaTxnGasLimits = (args, headers) => {
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
this.feeTokens = headers => {
return this.fetch(this.url('FeeTokens'), createHTTPRequest({}, headers)).then(res => {
return buildResponse(res).then(_data => {
return {
payload: _data.payload
isFeeRequired: _data.isFeeRequired,
tokens: _data.tokens
};

@@ -376,2 +389,12 @@ });

this.getMetaTxnNetworkFeeOptions = (args, headers) => {
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHTTPRequest(args, headers)).then(res => {
return buildResponse(res).then(_data => {
return {
options: _data.options
};
});
});
};
this.pushMetaTxn = (args, headers) => {

@@ -446,2 +469,3 @@ return this.fetch(this.url('PushMetaTxn'), createHTTPRequest(args, headers)).then(res => {

get ETHTxnStatus () { return ETHTxnStatus; },
get ContractType () { return ContractType; },
RelayerService: RelayerService

@@ -512,40 +536,30 @@ });

async gasRefundOptions(config, context, ...transactions) {
// chaind only supports refunds on a single token
// TODO: Add compatiblity for different refund options
const tokenFee = await this.service.tokenFee();
logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${JSON.stringify(tokenFee)}`); // No gas refund required
// NOTE/TODO: for a given `service` the feeTokens will not change between execution, so we should memoize this value
// for a short-period of time, perhaps for 1 day or in memory. Perhaps one day we can make this happen automatically
// with http cache response for this endpoint and service-worker.. lots of approaches
const feeTokens = await this.service.feeTokens();
if (!tokenFee.isFee || tokenFee.fee === ethers.constants.AddressZero) {
return [[]];
}
if (feeTokens.isFeeRequired) {
const symbols = feeTokens.tokens.map(token => token.symbol).join(', ');
logger.info(`[rpc-relayer/gasRefundOptions] relayer fees are required, accepted tokens are ${symbols}`);
const addr = addressOf(config, context);
const prevNonce = readSequenceNonce(...transactions); // Set temporal nonce to simulate meta-txn
const addr = addressOf(config, context);
const prevNonce = readSequenceNonce(...transactions); // Set temporal nonce to simulate meta-txn
if (prevNonce === undefined) {
transactions = appendNonce(transactions, await this.getNonce(config, context));
}
if (prevNonce === undefined) {
transactions = appendNonce(transactions, await this.getNonce(config, context));
}
const coder = ethers.utils.defaultAbiCoder;
const encoded = coder.encode([MetaTransactionsType], [sequenceTxAbiEncode(transactions)]);
const res = await this.service.getMetaTxnNetworkFeeOptions({
walletAddress: addr,
payload: encoded,
signers: config.signers.length
});
let decoded;
if (prevNonce === undefined) {
decoded = res.options.map(option => coder.decode([MetaTransactionsType], option)[0].map(txn => _extends({}, txn, {
to: txn.target
})));
const coder = ethers.utils.defaultAbiCoder;
const encoded = coder.encode([MetaTransactionsType], [sequenceTxAbiEncode(transactions)]);
const res = await this.service.getMetaTxnNetworkFeeOptions({
walletAddress: addr,
payload: encoded,
signers: config.signers.length
});
logger.info(`[rpc-relayer/gasRefundOptions] got refund options ${JSON.stringify(res.options)}`);
return res.options;
} else {
decoded = res.options.map(option => coder.decode([MetaTransactionsType], option)[0].map(txn => _extends({}, txn, {
to: txn.target,
nonce: prevNonce
})));
logger.info(`[rpc-relayer/gasRefundOptions] relayer fees are not required`);
return [];
}
logger.info(`[rpc-relayer/gasRefundOptions] got refund options ${JSON.stringify(decoded)}`);
return decoded;
}

@@ -552,0 +566,0 @@

@@ -5,5 +5,6 @@ import { providers } from 'ethers';

import { WalletConfig } from '@0xsequence/config';
import { proto } from './rpc-relayer';
export interface Relayer {
estimateGasLimits(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[]>;
gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[][]>;
gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<FeeOption[]>;
getNonce(config: WalletConfig, context: WalletContext, space?: number, blockTag?: providers.BlockTag): Promise<number>;

@@ -18,2 +19,3 @@ relay(signedTxs: SignedTransactions): Promise<providers.TransactionResponse>;

export { proto as RpcRelayerProto } from './rpc-relayer';
export declare type FeeOption = proto.FeeOption;
export declare function isRelayer(cand: any): cand is Relayer;

@@ -6,3 +6,3 @@ import { TransactionResponse } from '@ethersproject/providers';

import { WalletConfig } from '@0xsequence/config';
import { Relayer } from '.';
import { FeeOption, Relayer } from '.';
import { ProviderRelayer, ProviderRelayerOptions } from './provider-relayer';

@@ -17,5 +17,5 @@ export declare type LocalRelayerOptions = Omit<ProviderRelayerOptions, "provider"> & {

deployWallet(config: WalletConfig, context: WalletContext): Promise<TransactionResponse>;
gasRefundOptions(_config: WalletConfig, _context: WalletContext, ..._transactions: Transaction[]): Promise<Transaction[][]>;
gasRefundOptions(_config: WalletConfig, _context: WalletContext, ..._transactions: Transaction[]): Promise<FeeOption[]>;
relay(signedTxs: SignedTransactions): Promise<TransactionResponse>;
wait(metaTxnId: string | SignedTransactions, timeout: number): Promise<TransactionResponse>;
}

@@ -6,3 +6,3 @@ import { TransactionResponse, BlockTag, Provider } from '@ethersproject/providers';

import { BaseRelayer, BaseRelayerOptions } from './base-relayer';
import { Relayer } from '.';
import { FeeOption, Relayer } from '.';
export interface ProviderRelayerOptions extends BaseRelayerOptions {

@@ -15,3 +15,3 @@ provider: Provider;

constructor(options: ProviderRelayerOptions);
abstract gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[][]>;
abstract gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<FeeOption[]>;
abstract relay(signedTxs: SignedTransactions): Promise<TransactionResponse>;

@@ -18,0 +18,0 @@ estimateGasLimits(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[]>;

import { TransactionResponse, BlockTag } from '@ethersproject/providers';
import { Transaction, SignedTransactions } from '@0xsequence/transactions';
import { BaseRelayer, BaseRelayerOptions } from '../base-relayer';
import { Relayer } from '..';
import { FeeOption, Relayer } from '..';
import { WalletContext } from '@0xsequence/network';

@@ -18,3 +18,3 @@ import { WalletConfig } from '@0xsequence/config';

estimateGasLimits(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[]>;
gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[][]>;
gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<FeeOption[]>;
getNonce(config: WalletConfig, context: WalletContext, space?: number, blockTag?: BlockTag): Promise<number>;

@@ -21,0 +21,0 @@ relay(signedTxs: SignedTransactions): Promise<TransactionResponse>;

export declare const WebRPCVersion = "v1";
export declare const WebRPCSchemaVersion = "v0.3.0";
export declare const WebRPCSchemaHash = "a91267ba653a2d505e8e7c621cd95c9c2c34437a";
export declare const WebRPCSchemaHash = "9438009246584134620a2a88e9587ab12b77c63f";
export declare enum ETHTxnStatus {

@@ -14,2 +14,11 @@ UNKNOWN = "UNKNOWN",

}
export declare enum ContractType {
UNKNOWN = "UNKNOWN",
ERC20_TOKEN = "ERC20_TOKEN",
ERC721_TOKEN = "ERC721_TOKEN",
ERC1155_TOKEN = "ERC1155_TOKEN",
META_ERC20_WRAPPER = "META_ERC20_WRAPPER",
NIFTYSWAP = "NIFTYSWAP",
BRIDGE = "BRIDGE"
}
export interface Version {

@@ -51,2 +60,19 @@ webrpcVersion: string;

}
export interface FeeOption {
token: FeeToken;
to: string;
value: string;
gasLimit: number;
}
export interface FeeToken {
chainId: number;
name: string;
symbol: string;
type: ContractType;
decimals?: number;
logoURL: string;
contractAddress?: string;
originAddress?: string;
tokenID?: string;
}
export interface RelayerService {

@@ -62,4 +88,5 @@ ping(headers?: object): Promise<PingReturn>;

tokenFee(headers?: object): Promise<TokenFeeReturn>;
updateMetaTxnGasLimits(args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn>;
feeTokens(headers?: object): Promise<FeeTokensReturn>;
getMetaTxnNetworkFeeOptions(args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object): Promise<GetMetaTxnNetworkFeeOptionsReturn>;
updateMetaTxnGasLimits(args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn>;
pushMetaTxn(args: PushMetaTxnArgs, headers?: object): Promise<PushMetaTxnReturn>;

@@ -119,16 +146,22 @@ getMetaTxn(args: GetMetaTxnArgs, headers?: object): Promise<GetMetaTxnReturn>;

}
export interface GetMetaTxnNetworkFeeOptionsArgs {
export interface UpdateMetaTxnGasLimitsArgs {
walletAddress: string;
payload: string;
signers: number;
}
export interface GetMetaTxnNetworkFeeOptionsReturn {
options: Array<string>;
export interface UpdateMetaTxnGasLimitsReturn {
payload: string;
}
export interface UpdateMetaTxnGasLimitsArgs {
export interface FeeTokensArgs {
}
export interface FeeTokensReturn {
isFeeRequired: boolean;
tokens: Array<FeeToken>;
}
export interface GetMetaTxnNetworkFeeOptionsArgs {
walletAddress: string;
payload: string;
signers: number;
}
export interface UpdateMetaTxnGasLimitsReturn {
payload: string;
export interface GetMetaTxnNetworkFeeOptionsReturn {
options: Array<FeeOption>;
}

@@ -163,4 +196,5 @@ export interface PushMetaTxnArgs {

tokenFee: (headers?: object | undefined) => Promise<TokenFeeReturn>;
updateMetaTxnGasLimits: (args: UpdateMetaTxnGasLimitsArgs, headers?: object | undefined) => Promise<UpdateMetaTxnGasLimitsReturn>;
feeTokens: (headers?: object | undefined) => Promise<FeeTokensReturn>;
getMetaTxnNetworkFeeOptions: (args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object | undefined) => Promise<GetMetaTxnNetworkFeeOptionsReturn>;
updateMetaTxnGasLimits: (args: UpdateMetaTxnGasLimitsArgs, headers?: object | undefined) => Promise<UpdateMetaTxnGasLimitsReturn>;
pushMetaTxn: (args: PushMetaTxnArgs, headers?: object | undefined) => Promise<PushMetaTxnReturn>;

@@ -167,0 +201,0 @@ getMetaTxn: (args: GetMetaTxnArgs, headers?: object | undefined) => Promise<GetMetaTxnReturn>;

{
"name": "@0xsequence/relayer",
"version": "0.22.2",
"version": "0.23.0",
"description": "relayer sub-package for Sequence",

@@ -16,7 +16,7 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/relayer",

"dependencies": {
"@0xsequence/abi": "^0.22.2",
"@0xsequence/chaind": "^0.22.2",
"@0xsequence/config": "^0.22.2",
"@0xsequence/transactions": "^0.22.2",
"@0xsequence/utils": "^0.22.2",
"@0xsequence/abi": "^0.23.0",
"@0xsequence/chaind": "^0.23.0",
"@0xsequence/config": "^0.23.0",
"@0xsequence/transactions": "^0.23.0",
"@0xsequence/utils": "^0.23.0",
"@ethersproject/providers": "^5.0.24",

@@ -23,0 +23,0 @@ "ethers": "^5.0.32",

@@ -5,2 +5,3 @@ import { providers } from 'ethers'

import { WalletConfig } from '@0xsequence/config'
import { proto } from './rpc-relayer'

@@ -23,3 +24,3 @@ export interface Relayer {

...transactions: Transaction[]
): Promise<Transaction[][]>
): Promise<FeeOption[]>

@@ -41,2 +42,3 @@ // getNonce returns the transaction count/nonce for a wallet.

export { proto as RpcRelayerProto } from './rpc-relayer'
export type FeeOption = proto.FeeOption

@@ -43,0 +45,0 @@ export function isRelayer(cand: any): cand is Relayer {

@@ -6,3 +6,3 @@ import { TransactionResponse } from '@ethersproject/providers'

import { WalletConfig } from '@0xsequence/config'
import { Relayer } from '.'
import { FeeOption, Relayer } from '.'
import { ProviderRelayer, ProviderRelayerOptions } from './provider-relayer'

@@ -41,4 +41,4 @@

..._transactions: Transaction[]
): Promise<Transaction[][]> {
return [[]]
): Promise<FeeOption[]> {
return []
}

@@ -45,0 +45,0 @@

@@ -8,3 +8,3 @@ import { TransactionResponse, BlockTag, Provider } from '@ethersproject/providers'

import { BaseRelayer, BaseRelayerOptions } from './base-relayer'
import { Relayer } from '.'
import { FeeOption, Relayer } from '.'

@@ -29,3 +29,3 @@ const DEFAULT_GAS_LIMIT = ethers.BigNumber.from(800000)

abstract gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[][]>
abstract gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<FeeOption[]>
abstract relay(signedTxs: SignedTransactions): Promise<TransactionResponse>

@@ -32,0 +32,0 @@

@@ -15,3 +15,3 @@ import { TransactionResponse, Provider, BlockTag } from '@ethersproject/providers'

import { BaseRelayer, BaseRelayerOptions } from '../base-relayer'
import { Relayer } from '..'
import { FeeOption, Relayer } from '..'
import { WalletContext } from '@0xsequence/network'

@@ -100,51 +100,34 @@ import { WalletConfig, addressOf } from '@0xsequence/config'

async gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[][]> {
// chaind only supports refunds on a single token
// TODO: Add compatiblity for different refund options
const tokenFee = await this.service.tokenFee()
async gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<FeeOption[]> {
// NOTE/TODO: for a given `service` the feeTokens will not change between execution, so we should memoize this value
// for a short-period of time, perhaps for 1 day or in memory. Perhaps one day we can make this happen automatically
// with http cache response for this endpoint and service-worker.. lots of approaches
const feeTokens = await this.service.feeTokens()
logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${JSON.stringify(tokenFee)}`)
if (feeTokens.isFeeRequired) {
const symbols = feeTokens.tokens.map(token => token.symbol).join(', ')
logger.info(`[rpc-relayer/gasRefundOptions] relayer fees are required, accepted tokens are ${symbols}`)
// No gas refund required
if (!tokenFee.isFee || tokenFee.fee === ethers.constants.AddressZero) {
return [[]]
}
const addr = addressOf(config, context)
const prevNonce = readSequenceNonce(...transactions)
const addr = addressOf(config, context)
const prevNonce = readSequenceNonce(...transactions)
// Set temporal nonce to simulate meta-txn
if (prevNonce === undefined) {
transactions = appendNonce(transactions, await this.getNonce(config, context))
}
// Set temporal nonce to simulate meta-txn
if (prevNonce === undefined) {
transactions = appendNonce(transactions, await this.getNonce(config, context))
}
const coder = ethers.utils.defaultAbiCoder
const encoded = coder.encode([MetaTransactionsType], [sequenceTxAbiEncode(transactions)])
const res = await this.service.getMetaTxnNetworkFeeOptions({
walletAddress: addr,
payload: encoded,
signers: config.signers.length
})
const coder = ethers.utils.defaultAbiCoder
const encoded = coder.encode([MetaTransactionsType], [sequenceTxAbiEncode(transactions)])
const res = await this.service.getMetaTxnNetworkFeeOptions({
walletAddress: addr,
payload: encoded,
signers: config.signers.length
})
let decoded: Transaction[][]
if (prevNonce === undefined) {
decoded = res.options.map(option =>
coder.decode([MetaTransactionsType], option)[0].map((txn: TransactionEncoded) => ({
...txn,
to: txn.target
}))
)
logger.info(`[rpc-relayer/gasRefundOptions] got refund options ${JSON.stringify(res.options)}`)
return res.options
} else {
decoded = res.options.map(option =>
coder.decode([MetaTransactionsType], option)[0].map((txn: TransactionEncoded) => ({
...txn,
to: txn.target,
nonce: prevNonce
}))
)
logger.info(`[rpc-relayer/gasRefundOptions] relayer fees are not required`)
return []
}
logger.info(`[rpc-relayer/gasRefundOptions] got refund options ${JSON.stringify(decoded)}`)
return decoded
}

@@ -151,0 +134,0 @@

/* eslint-disable */
// relayer v0.3.0 a91267ba653a2d505e8e7c621cd95c9c2c34437a
// relayer v0.3.0 9438009246584134620a2a88e9587ab12b77c63f
// --

@@ -14,3 +14,3 @@ // This file has been generated by https://github.com/webrpc/webrpc using gen/typescript

// Schema hash generated from your RIDL schema
export const WebRPCSchemaHash = "a91267ba653a2d505e8e7c621cd95c9c2c34437a"
export const WebRPCSchemaHash = "9438009246584134620a2a88e9587ab12b77c63f"

@@ -32,2 +32,12 @@

export enum ContractType {
UNKNOWN = 'UNKNOWN',
ERC20_TOKEN = 'ERC20_TOKEN',
ERC721_TOKEN = 'ERC721_TOKEN',
ERC1155_TOKEN = 'ERC1155_TOKEN',
META_ERC20_WRAPPER = 'META_ERC20_WRAPPER',
NIFTYSWAP = 'NIFTYSWAP',
BRIDGE = 'BRIDGE'
}
export interface Version {

@@ -75,2 +85,21 @@ webrpcVersion: string

export interface FeeOption {
token: FeeToken
to: string
value: string
gasLimit: number
}
export interface FeeToken {
chainId: number
name: string
symbol: string
type: ContractType
decimals?: number
logoURL: string
contractAddress?: string
originAddress?: string
tokenID?: string
}
export interface RelayerService {

@@ -86,4 +115,5 @@ ping(headers?: object): Promise<PingReturn>

tokenFee(headers?: object): Promise<TokenFeeReturn>
updateMetaTxnGasLimits(args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn>
feeTokens(headers?: object): Promise<FeeTokensReturn>
getMetaTxnNetworkFeeOptions(args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object): Promise<GetMetaTxnNetworkFeeOptionsReturn>
updateMetaTxnGasLimits(args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn>
pushMetaTxn(args: PushMetaTxnArgs, headers?: object): Promise<PushMetaTxnReturn>

@@ -153,18 +183,25 @@ getMetaTxn(args: GetMetaTxnArgs, headers?: object): Promise<GetMetaTxnReturn>

}
export interface GetMetaTxnNetworkFeeOptionsArgs {
export interface UpdateMetaTxnGasLimitsArgs {
walletAddress: string
payload: string
signers: number
}
export interface GetMetaTxnNetworkFeeOptionsReturn {
options: Array<string>
export interface UpdateMetaTxnGasLimitsReturn {
payload: string
}
export interface UpdateMetaTxnGasLimitsArgs {
export interface FeeTokensArgs {
}
export interface FeeTokensReturn {
isFeeRequired: boolean
tokens: Array<FeeToken>
}
export interface GetMetaTxnNetworkFeeOptionsArgs {
walletAddress: string
payload: string
signers: number
}
export interface UpdateMetaTxnGasLimitsReturn {
payload: string
export interface GetMetaTxnNetworkFeeOptionsReturn {
options: Array<FeeOption>
}

@@ -322,9 +359,9 @@ export interface PushMetaTxnArgs {

getMetaTxnNetworkFeeOptions = (args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object): Promise<GetMetaTxnNetworkFeeOptionsReturn> => {
updateMetaTxnGasLimits = (args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn> => {
return this.fetch(
this.url('GetMetaTxnNetworkFeeOptions'),
this.url('UpdateMetaTxnGasLimits'),
createHTTPRequest(args, headers)).then((res) => {
return buildResponse(res).then(_data => {
return {
options: <Array<string>>(_data.options)
payload: <string>(_data.payload)
}

@@ -335,9 +372,23 @@ })

updateMetaTxnGasLimits = (args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn> => {
feeTokens = (headers?: object): Promise<FeeTokensReturn> => {
return this.fetch(
this.url('UpdateMetaTxnGasLimits'),
this.url('FeeTokens'),
createHTTPRequest({}, headers)
).then((res) => {
return buildResponse(res).then(_data => {
return {
isFeeRequired: <boolean>(_data.isFeeRequired),
tokens: <Array<FeeToken>>(_data.tokens)
}
})
})
}
getMetaTxnNetworkFeeOptions = (args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object): Promise<GetMetaTxnNetworkFeeOptionsReturn> => {
return this.fetch(
this.url('GetMetaTxnNetworkFeeOptions'),
createHTTPRequest(args, headers)).then((res) => {
return buildResponse(res).then(_data => {
return {
payload: <string>(_data.payload)
options: <Array<FeeOption>>(_data.options)
}

@@ -344,0 +395,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc