Skip to content

Commit

Permalink
fix: NEAR proof sharding fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
paouvrard committed Oct 29, 2021
1 parent 28a93fa commit 555c3c4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface TransferOptions {
nearAccount?: Account
ethClientAddress?: string
ethClientAbi?: string
nearTokenFactoryAccount?: string
}

const transferDraft: TransferDraft = {
Expand Down Expand Up @@ -765,7 +766,7 @@ export async function checkSync (
if (nearOnEthClientBlockHeight > burnBlockHeight) {
proof = await findNearProof(
last(transfer.nearBurnReceiptIds),
transfer.sender,
options.nearTokenFactoryAccount ?? bridgeParams.nearTokenFactoryAccount,
nearOnEthClientBlockHeight,
nearAccount,
provider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export interface TransferOptions {
ethClientAddress?: string
ethClientAbi?: string
auroraProvider?: ethers.providers.JsonRpcProvider
auroraEvmAccount?: string
}

const transferDraft: TransferDraft = {
Expand Down Expand Up @@ -725,7 +726,7 @@ export async function checkSync (
if (nearOnEthClientBlockHeight > burnBlockHeight) {
proof = await findNearProof(
last(transfer.nearBurnReceiptIds),
transfer.sender,
options.auroraEvmAccount ?? bridgeParams.auroraEvmAccount,
nearOnEthClientBlockHeight,
nearAccount,
provider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ export async function checkSync (
if (nearOnEthClientBlockHeight > withdrawBlockHeight) {
proof = await findNearProof(
last(transfer.burnReceiptIds),
transfer.sender,
options.auroraEvmAccount ?? bridgeParams.auroraEvmAccount,
nearOnEthClientBlockHeight,
nearAccount,
provider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ export async function checkSync (
if (nearOnEthClientBlockHeight > lockReceiptBlockHeight) {
proof = await findNearProof(
last(transfer.lockReceiptIds),
transfer.sender,
options.nativeNEARLockerAddress ?? bridgeParams.nativeNEARLockerAddress,
nearOnEthClientBlockHeight,
nearAccount,
provider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface TransferOptions {
erc20Abi?: string
nep141Factory?: string
erc20LockerAbi?: string
nearTokenFactoryAccount?: string
}

class TransferError extends Error {}
Expand Down Expand Up @@ -776,7 +777,7 @@ export async function checkSync (
if (nearOnEthClientBlockHeight > withdrawBlockHeight) {
proof = await findNearProof(
last(transfer.withdrawReceiptIds),
transfer.sender,
options.nearTokenFactoryAccount ?? bridgeParams.nearTokenFactoryAccount,
nearOnEthClientBlockHeight,
nearAccount,
provider,
Expand Down
10 changes: 9 additions & 1 deletion packages/utils/src/borshify-proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ export function borshifyOutcomeProof (proof: any): Buffer {

statusToBuffer(proof.outcome_proof.outcome.status),

utils.toBN(0).toBuffer('le', 4),
utils.toBN(proof.outcome_root_proof.length).toBuffer('le', 4),
Buffer.concat(
proof.outcome_root_proof.map((orp: any) =>
Buffer.concat([
bs58.decode(orp.hash),
Buffer.from([orp.direction === 'Right' ? 1 : 0])
])
)
),

bs58.decode(proof.block_header_lite.prev_block_hash),
bs58.decode(proof.block_header_lite.inner_rest_hash),
Expand Down

0 comments on commit 555c3c4

Please sign in to comment.