Skip to content

Commit

Permalink
use [email protected] and new getProof
Browse files Browse the repository at this point in the history
  • Loading branch information
troggy committed Apr 24, 2020
1 parent 26dfb92 commit 27a6ab3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"ethereumjs-util": "6.0.0",
"fork-ts-checker-webpack-plugin": "^0.4.15",
"jsbi-utils": "^1.0.0",
"leap-core": "0.38.0",
"leap-core": "2.0.0",
"mobx": "^5.0.3",
"mobx-react": "^5.2.3",
"prop-types": "^15.6.1",
Expand Down
40 changes: 17 additions & 23 deletions src/stores/unspents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,10 @@ export class UnspentsStore {
});
}

private exitDeposit(
unspentDeposit: UnspentWithTx,
fallbackPeriodData: PeriodData
) {
return getProof(
web3PlasmaStore.instance,
unspentDeposit.transaction,
fallbackPeriodData
).then(txProof =>
private exitDeposit(unspentDeposit: UnspentWithTx) {
return getProof(web3PlasmaStore.instance, unspentDeposit.transaction, {
excludePrevHashFromProof: true,
}).then(txProof =>
exitHandlerStore.startExit([], txProof, unspentDeposit.outpoint.index, 0)
);
}
Expand All @@ -146,23 +141,19 @@ export class UnspentsStore {
public exitUnspent(unspent: UnspentWithTx) {
const tx = Tx.fromRaw(unspent.transaction.raw);

const { signer } = operatorStore.slots[0];

const fallbackPeriodData = { slotId: 0, validatorAddress: signer };

if (tx.type === Type.DEPOSIT) {
return this.exitDeposit(unspent, fallbackPeriodData);
return this.exitDeposit(unspent);
}

getYoungestInputTx(web3PlasmaStore.instance, tx)
.then(inputTx =>
Promise.all([
getProof(
web3PlasmaStore.instance,
unspent.transaction,
fallbackPeriodData
),
getProof(web3PlasmaStore.instance, inputTx.tx, fallbackPeriodData),
getProof(web3PlasmaStore.instance, unspent.transaction, {
excludePrevHashFromProof: true,
}),
getProof(web3PlasmaStore.instance, inputTx.tx, {
excludePrevHashFromProof: true,
}),
inputTx.index,
])
)
Expand Down Expand Up @@ -207,7 +198,6 @@ export class UnspentsStore {
@autobind
private finalizeFastExit(exit) {
console.log('Finalizing fast exit', exit, operatorStore.slots);
const { signer } = operatorStore.slots[0];
const { unspent, sig, rawTx, sigHashBuff } = exit;
const vBuff = Buffer.alloc(32);
vBuff.writeInt8(sig.v, 31);
Expand All @@ -220,8 +210,12 @@ export class UnspentsStore {
])
);
return Promise.all([
getProof(web3PlasmaStore.instance, rawTx),
getProof(web3PlasmaStore.instance, unspent.transaction),
getProof(web3PlasmaStore.instance, rawTx, {
excludePrevHashFromProof: true,
}),
getProof(web3PlasmaStore.instance, unspent.transaction, {
excludePrevHashFromProof: true,
}),
0,
]).then(([txProof, inputProof, inputIndex]) => {
// call api
Expand Down
22 changes: 18 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3660,6 +3660,11 @@ [email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.1.1.tgz#47786bdaa087caf7b1b75e73abc5c7d540158cd0"

[email protected]:
version "3.1.2"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7"
integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==

eventemitter3@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.0.tgz#090b4d6cdbd645ed10bf750d4b5407942d7ba163"
Expand Down Expand Up @@ -5108,15 +5113,16 @@ lcid@^2.0.0:
dependencies:
invert-kv "^2.0.0"

leap-core@0.38.0:
version "0.38.0"
resolved "https://registry.yarnpkg.com/leap-core/-/leap-core-0.38.0.tgz#808ddff55bb5189771e0fbc2a086210529a17b4f"
integrity sha512-mjS3UOiJp05wRKRsURI1u8XzZ/4HmScpj3cpAGRC9ls4QShu/XAf2CpK297PWAfHT+xQTLyd3OxBNujhuTXamA==
leap-core@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/leap-core/-/leap-core-2.0.0.tgz#e0ce5000bf77afd72f5a72236d6b80e82e8d3f19"
integrity sha512-DqbWSrYNz+ZGIROXfT7SBUC0FHon6rrv6I7RCrxbzqjDsHHh6lmpMW6v+kkJtYYRe6TkalxPZMz0HRgo+ndtbw==
dependencies:
"@types/web3" "^1.0.18"
ethereumjs-util "6.0.0"
jsbi-utils "^1.0.0"
node-fetch "^2.3.0"
web3-core-promievent "^1.2.4"

less-loader@^4.1.0:
version "4.1.0"
Expand Down Expand Up @@ -8601,6 +8607,14 @@ [email protected]:
any-promise "1.3.0"
eventemitter3 "1.1.1"

web3-core-promievent@^1.2.4:
version "1.2.6"
resolved "https://registry.yarnpkg.com/web3-core-promievent/-/web3-core-promievent-1.2.6.tgz#b1550a3a4163e48b8b704c1fe4b0084fc2dad8f5"
integrity sha512-km72kJef/qtQNiSjDJJVHIZvoVOm6ytW3FCYnOcCs7RIkviAb5JYlPiye0o4pJOLzCXYID7DK7Q9bhY8qWb1lw==
dependencies:
any-promise "1.3.0"
eventemitter3 "3.1.2"

[email protected]:
version "1.0.0-beta.33"
resolved "https://registry.yarnpkg.com/web3-core-requestmanager/-/web3-core-requestmanager-1.0.0-beta.33.tgz#7a36c40354002dfb179ca2dbdb6a6012c9f719eb"
Expand Down

0 comments on commit 27a6ab3

Please sign in to comment.