Skip to content

Commit

Permalink
Merge pull request #7672 from ScopeLift/zksync-signing-updates
Browse files Browse the repository at this point in the history
Update zksync to accomodate fee on setSigningKey
  • Loading branch information
octavioamu authored Oct 13, 2020
2 parents aa18d0b + 831c653 commit cba3453
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -1524,20 +1524,26 @@ Vue.component('grants-cart', {
throw new Error('Unknown account');
}

// Get the first token listed and use that to pay for signing key transaction
const syncWalletState = await syncWallet.getAccountState();
const tokensInWallet = Object.keys(syncWalletState.committed.balances);
const feeToken = tokensInWallet[0];

// Determine how to set key based on wallet type
let changePubkey;

if (syncWallet.ethSignerType.verificationMethod === 'ECDSA') {
console.log(' Using ECDSA to set signing key');
changePubkey = await syncWallet.setSigningKey();
changePubkey = await syncWallet.setSigningKey({ feeToken });
} else {
console.log(' Using ERC-1271 to set signing key. This requires an on-chain transaction');
const signingKeyTx = await syncWallet.onchainAuthSigningKey();

changePubkey = await syncWallet.setSigningKey('committed', true);
changePubkey = await syncWallet.setSigningKey({ feeToken, onchainAuth: true });
}

// Wait until the tx is committed
console.log('Signing key set, waiting for transaction receipt');
await changePubkey.awaitReceipt();
console.log('✅ specified sync wallet is ready to use on zkSync');
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/grants/templates/grants/cart-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ <h1 class="font-bigger-4 font-weight-bold mt-2">
{% comment %} ================================================================= {% endcomment %}

<script type="text/javascript" src="https://cdn.ethers.io/lib/ethers-5.0.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].4/dist/main.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].5/dist/main.js"></script>
<script type="text/javascript">
(async () => {
// Loads and compiles wasm library
Expand Down

0 comments on commit cba3453

Please sign in to comment.