Skip to content

Commit

Permalink
fix: change checkSpendingCondition according to leapdao/leap-node#242
Browse files Browse the repository at this point in the history
  • Loading branch information
troggy committed Jun 15, 2019
1 parent 7cf9591 commit 4a8c519
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"ethereumjs-util": "^6.1.0",
"ganache-cli": "^6.2.3",
"jsbi-utils": "^1.0.0",
"leap-core": "^0.30.1",
"leap-core": "^0.32.1-pr.0",
"web3": "1.0.0-beta.37"
}
}
6 changes: 3 additions & 3 deletions tests/0_spendingCondition.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const { transfer } = require('./actions/transfer');
const ethUtil = require('ethereumjs-util');
const spendingConditionABI = require('../src/spendingConditionABI');
const { Tx, Input, Output } = require('leap-core');
const { Tx, Input, Output, Consensus } = require('leap-core');
const { getAddress } = Consensus.spendingCondition;

module.exports = async function(contracts, nodes, accounts, web3) {
const alice = accounts[0].addr;
Expand All @@ -10,8 +11,7 @@ module.exports = async function(contracts, nodes, accounts, web3) {
const bobPriv = accounts[1].privKey;
const spCode = '0x608060405234801561001057600080fd5b506004361061002e5760e060020a6000350463d01a81e18114610033575b600080fd5b61005f6004803603604081101561004957600080fd5b50600160a060020a038135169060200135610061565b005b6040805160e060020a6370a08231028152306004820152905173111111111111111111111111111111111111111191600091849184916370a0823191602480820192602092909190829003018186803b1580156100bd57600080fd5b505afa1580156100d1573d6000803e3d6000fd5b505050506040513d60208110156100e757600080fd5b50516040805160e060020a63a9059cbb028152600160a060020a03888116600483015260248201889052915193909203935084169163a9059cbb916044808201926020929091908290030181600087803b15801561014457600080fd5b505af1158015610158573d6000803e3d6000fd5b505050506040513d602081101561016e57600080fd5b505060008111156101f8576040805160e060020a63a9059cbb028152306004820152602481018390529051600160a060020a0384169163a9059cbb9160448083019260209291908290030181600087803b1580156101cb57600080fd5b505af11580156101df573d6000803e3d6000fd5b505050506040513d60208110156101f557600080fd5b50505b5050505056fea165627a7a72305820b6375cb3c7f659844afea0adf999ea78d73fd047f5823fbe1447f8051fe0189b0029'.replace('1111111111111111111111111111111111111111', contracts.token.options.address.replace('0x', '').toLowerCase());
const codeBuf = Buffer.from(spCode.replace('0x', ''), 'hex');
const spAddrBuf = ethUtil.ripemd160(codeBuf);
const spAddr = `0x${spAddrBuf.toString('hex')}`;
const spAddr = getAddress(codeBuf);

console.log("╔══════════════════════════════════════════╗");
console.log("║ Test: Fund SP and claim from it ║");
Expand Down
7 changes: 4 additions & 3 deletions tests/8_breeding.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const assert = require('assert');
const ethUtil = require('ethereumjs-util');
const { Tx, Input, Output, Outpoint } = require('leap-core');
const { Tx, Input, Output, Outpoint, Consensus } = require('leap-core');

const exitUnspent = require('./actions/exitUnspent');
const minePeriod = require('./actions/minePeriod');

const TOKEN = require('../build/contracts/build/contracts/ERC1949.json');

const { getAddress } = Consensus.spendingCondition;

const BreedingCondition =
'6080604052348015600f57600080fd5b5060043610602b5760e060020a6000350463689dcafc81146030575b600080fd5b606960048036036080811015604457600080fd5b50803590600160a060020a03602082013581169160408101359160609091013516606b565b005b6040805160e060020a63451da9f902815260048101869052600160a060020a038581166024830152604482018590529151839283169163451da9f991606480830192600092919082900301818387803b15801560c657600080fd5b505af115801560d9573d6000803e3d6000fd5b50505050505050505056fea165627a7a72305820ff50695e9e2f7357f76cac1b8adb0d5d43b7930e23a23bdae6c9f81c5fcddfcc0029';

Expand Down Expand Up @@ -91,8 +93,7 @@ module.exports = async function(contracts, [node], accounts, web3) {
assert.equal(unspents[0].output.data, tokenData, 'tokenData should match');

const script = Buffer.from(BreedingCondition, 'hex');
const scriptHash = ethUtil.ripemd160(script);
const spAddr = `0x${scriptHash.toString('hex')}`;
const spAddr = getAddress(script);
// XXX: add support for approval in ERC1949
let transferTx = Tx.transfer(
[
Expand Down
21 changes: 4 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,6 @@ babel-plugin-transform-strict-mode@^6.24.1:
babel-runtime "^6.22.0"
babel-types "^6.24.1"

babel-polyfill@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
dependencies:
babel-runtime "^6.26.0"
core-js "^2.5.0"
regenerator-runtime "^0.10.5"

babel-preset-env@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a"
Expand Down Expand Up @@ -2447,13 +2439,12 @@ lcid@^1.0.0:
dependencies:
invert-kv "^1.0.0"

leap-core@^0.30.1:
version "0.30.1"
resolved "https://registry.yarnpkg.com/leap-core/-/leap-core-0.30.1.tgz#efe8c88f78e8a7c5e2a0e0b9611282cedd117076"
integrity sha512-jJDovG7vPzzOr7LhpAM8BLs17+baTjz2NCaqLPPJGa7pyDuSDItvGVQolaOc9ogHupCNzXqFX/8KnhxImrjneg==
leap-core@^0.32.1-pr.0:
version "0.32.1-pr.0"
resolved "https://registry.yarnpkg.com/leap-core/-/leap-core-0.32.1-pr.0.tgz#23f65b2b87c5c0894338fc503682d4637034919f"
integrity sha512-YKyX5DcpigB8PNJdDOCqqgMKPhxKrlitJQxC3bbJp40EIMTxbU85la3utz7+6Km+Kr5qH0SM8EAKtZAbPwXwDQ==
dependencies:
"@types/web3" "^1.0.18"
babel-polyfill "^6.26.0"
ethereumjs-util "6.0.0"
jsbi-utils "^1.0.0"
node-fetch "^2.3.0"
Expand Down Expand Up @@ -3239,10 +3230,6 @@ regenerate@^1.2.1:
version "1.4.0"
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11"

regenerator-runtime@^0.10.5:
version "0.10.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"

regenerator-runtime@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
Expand Down

0 comments on commit 4a8c519

Please sign in to comment.