Skip to content

Commit

Permalink
safe pin
Browse files Browse the repository at this point in the history
  • Loading branch information
fewensa committed Apr 12, 2024
1 parent ec6ecbe commit 45030c3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/ecosys/definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ features:
approve:
disable:
- ring

safepin:
46: # darwinia
safeTxGas: 613599
gasPrice: 154000000000
14 changes: 9 additions & 5 deletions src/ecosys/safe.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ async function initSafe(options) {
}


export async function propose(options = {safeSdk, safeService, transactions, safeAddress, senderAddress}) {
const {safeSdk, safeService, transactions, safeAddress, senderAddress} = options;
export async function propose(options = {definition, safeSdk, safeService, transactions, safeAddress, senderAddress}) {
const {definition, safeSdk, safeService, transactions, safeAddress, senderAddress} = options;
const chainId = await safeSdk.getChainId();
const remoteNonce = await safeSdk.getNonce();

const safepin = definition.safepin[chainId];

let nonce;
if (cachedNonce[chainId]) {
const cnonce = cachedNonce[chainId];
Expand All @@ -93,11 +95,13 @@ export async function propose(options = {safeSdk, safeService, transactions, saf
nonce = remoteNonce;
}

let createTransactionOptions = { nonce };
if (safepin) {
createTransactionOptions = {...createTransactionOptions, ...safepin};
}
const safeTransaction = await safeSdk.createTransaction({
transactions,
options: {
nonce,
},
options: createTransactionOptions,
});
const safeTxHash = await safeSdk.getTransactionHash(safeTransaction);
const senderSignature = await safeSdk.signTransaction(safeTransaction);
Expand Down
2 changes: 2 additions & 0 deletions src/register/lnv2_default.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ async function registerWithSafe(options, callOptions) {

if (p0Transactions.length) {
const p0 = await safe.propose({
definition,
safeSdk: targetSafeSdk,
safeService: targetSafeService,
safeAddress: register.safeWalletAddress,
Expand Down Expand Up @@ -225,6 +226,7 @@ async function registerWithSafe(options, callOptions) {
}

const p1 = await safe.propose({
definition,
safeSdk: sourceSafeSdk,
safeService: sourceSafeService,
safeAddress: register.safeWalletAddress,
Expand Down
2 changes: 2 additions & 0 deletions src/register/lnv2_opposite.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ async function registerWithSafe(options, callOptions) {

if (p0Transactions.length) {
const p0 = await safe.propose({
definition,
safeSdk: targetSafeSdk,
safeService: targetSafeService,
safeAddress: register.safeWalletAddress,
Expand All @@ -150,6 +151,7 @@ async function registerWithSafe(options, callOptions) {
}

const p1 = await safe.propose({
definition,
safeSdk: sourceSafeSdk,
safeService: sourceSafeService,
safeAddress: register.safeWalletAddress,
Expand Down
1 change: 1 addition & 0 deletions src/register/lnv3.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ async function registerWithSafe(options, callOptions) {
}

const p0 = await safe.propose({
definition,
safeSdk: sourceSafeSdk,
safeService: sourceSafeService,
safeAddress: register.safeWalletAddress,
Expand Down

0 comments on commit 45030c3

Please sign in to comment.