Migrate to sequence.js v1.1.0
This document explains how to migrate to sequence.js v1.1.0 from earlier versions.
Changes
Init library
The initWallet
function's network
parameter has been replaced. Now, it accepts a configuration object that may include a defaultNetwork
parameter.
Before:
const wallet = await sequence.initWallet('mainnet')
After:
const wallet = await sequence.initWallet({ defaultNetwork: 'mainnet' })
The parameter remains optional. If not provided, the default network will be mainnet
.
Wallet class instance
Previously, both initWallet
and getWallet
returned a Wallet
instance, which could be used to access both a provider and a signer. Now, they return a SequenceProvider
, which already functions as the provider while offering sequence-specific methods.
Methods such as getSigner
and getProvider
are still available in SequenceProvider
. Note that calling getProvider()
will return this
.
Before:
const wallet = await sequence.initWallet('mainnet')
const provider = wallet.getProvider()
const signer = wallet.getSigner()
After:
const provider = await sequence.initWallet({ defaultNetwork: 'mainnet' })
const signer = provider.getSigner()
Custom network provider and signer
The getProvider
and getSigner
methods now accept an optional network
parameter. This is handy when you wish to use a custom provider or signer for a specific network. In such cases, a tailored network provider/signer is created, and the method does not return this
.
Connect wallet
The connect
function now mandates an app
parameter, representing the app name requesting the connection. This name will be displayed to the user.
Before:
const connectDetails = await wallet.connect()
After:
const connectDetails = await wallet.connect({ app: 'Your app name' })
Sign EIP-6492 messages
EIP-6492 allows the wallet to sign messages without first executing a transaction. This feature should be utilized only when the signature will be validated by software supporting EIP-6492, such as the sequence.js library. All sign
methods of the signer use EIP-6492 by default.
To opt out of EIP-6492, previously you could append a false
value at the end of each sign method; now you can pass an eip6492
named argument.
Before:
const signature = await signer.signMessage(message, undefined, false)
After:
const signature = await signer.signMessage(message, { eip6492: false })
Operate on a specific network
Earlier, most methods of the signer and provider would target the default network. You could alter this by adding a positional network
argument at the end of each method. This has been swapped with a named chainId
argument, which can be combined with other named arguments, such as eip6492
.
Before:
const balance = await provider.sendTransaction(transaction, 'rinkeby')
After:
const balance = await provider.sendTransaction(transaction, { chainId: 'rinkeby' })
Send batch transactions
Previously, separate methods (sendTransactionBatch
and sendTransaction
) were provided for batch transactions. Now, there's just sendTransaction
that can receive either an array of transactions or a singular transaction.
Before:
const receipt1 = await provider.sendTransactionBatch([transaction1, transaction2])
After:
const receipt1 = await provider.sendTransaction([transaction1, transaction2])
Removal of internal state methods
Some internal state methods have been either removed or deprecated. This encompasses methods for:
- Determining if the wallet is deployed
- Retrieving the wallet's "sequence context"
- Accessing the "inner configuration" of the wallet (i.e., its comprising signers)
Should you require any of these methods, please reach out to support.
Rainbowkit Connector
Compatibility with the Rainbowkit connector has been largely retained. However, the configuration for defaultNetwork
has been relocated. Previously, it was set under connect.networkId
. Now, it has been elevated to a top-level property named defaultNetwork
.
Before:
sequenceWallet({
chains,
connect: {
app: 'Demo app',
networkId: 1,
},
})
After:
sequenceWallet({
chains,
defaultNetwork: 1,
connect: {
app: 'Demo app',
},
})
Wagmi Connector
The Wagmi connector has undergone the same modifications as the Rainbowkit connector.
Before:
new SequenceConnector({
chains,
connect: {
app: 'Demo app',
networkId: 1,
},
})
After:
new SequenceConnector({
chains,
defaultNetwork: 1,
connect: {
app: 'Demo app',
},
})
Rainbowkit & Wagmi Connector - EIP-6492 Signatures
In earlier versions, EIP-6492 signatures were activated globally either through the useEIP6492
configuration property or the useSequenceEIP6492
method. Both methods have now been deprecated. Attempting to initialize with useEIP6492
will result in a runtime error.
For utilizing EIP-6492 in the updated version, you'll need to explicitly invoke sequence_sign
or sequence_signTypedData_v4
on the connector.
Before:
new SequenceConnector({
chains,
connect: {
app: 'Demo app',
networkId: 1,
useEIP6492: true,
},
})
After:
// NOTE: The connector is now initialized without the useEIP6492 property.
// ...
const sig = await walletClient.request({
method: 'sequence_sign',
params: [message, account]
}) as string;
Both @0xsequence/wagmi-connector
and @0xsequence/rainbowkit-plugin
versions 2.1.0
require 0xsequence
as a peer dependency. Ensure that you are using version 1.1.0
or higher of 0xsequence
. Utilizing older versions may lead to instability in your application.
This is essential to maintain compatibility and ensure the stable operation of your connectors and plugins.