@0xcert/ethereum-asset-ledger
Advanced tools
Comparing version 1.0.0-rc1 to 1.0.0-rc10
import { GenericProvider, Mutation } from '@0xcert/ethereum-generic-provider'; | ||
import { AssetLedgerAbility, AssetLedgerBase, AssetLedgerCapability, AssetLedgerDeployRecipe, AssetLedgerInfo, AssetLedgerItem, AssetLedgerItemRecipe, AssetLedgerObjectUpdateRecipe, AssetLedgerTransferRecipe, AssetLedgerUpdateRecipe, OrderGatewayBase } from '@0xcert/scaffold'; | ||
export declare class AssetLedger implements AssetLedgerBase { | ||
protected $id: string; | ||
protected $provider: GenericProvider; | ||
protected _id: string; | ||
protected _provider: GenericProvider; | ||
static deploy(provider: GenericProvider, recipe: AssetLedgerDeployRecipe): Promise<Mutation>; | ||
@@ -18,2 +18,4 @@ static getInstance(provider: GenericProvider, id: string): AssetLedger; | ||
getInfo(): Promise<AssetLedgerInfo>; | ||
getAssetIdAt(index: number): Promise<number>; | ||
getAccountAssetIdAt(accountId: string, index: number): Promise<number>; | ||
isApprovedAccount(assetId: string, accountId: string | OrderGatewayBase): Promise<boolean>; | ||
@@ -20,0 +22,0 @@ isTransferable(): Promise<boolean>; |
@@ -26,5 +26,7 @@ "use strict"; | ||
const get_abilities_1 = require("../queries/get-abilities"); | ||
const get_account_asset_id_at_1 = require("../queries/get-account-asset-id-at"); | ||
const get_approved_account_1 = require("../queries/get-approved-account"); | ||
const get_asset_1 = require("../queries/get-asset"); | ||
const get_asset_account_1 = require("../queries/get-asset-account"); | ||
const get_asset_id_at_1 = require("../queries/get-asset-id-at"); | ||
const get_balance_1 = require("../queries/get-balance"); | ||
@@ -45,10 +47,10 @@ const get_capabilities_1 = require("../queries/get-capabilities"); | ||
constructor(provider, id) { | ||
this.$id = ethereum_utils_1.normalizeAddress(id); | ||
this.$provider = provider; | ||
this._id = ethereum_utils_1.normalizeAddress(id); | ||
this._provider = provider; | ||
} | ||
get id() { | ||
return this.$id; | ||
return this._id; | ||
} | ||
get provider() { | ||
return this.$provider; | ||
return this._provider; | ||
} | ||
@@ -90,2 +92,12 @@ getAbilities(accountId) { | ||
} | ||
getAssetIdAt(index) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return get_asset_id_at_1.default(this, index); | ||
}); | ||
} | ||
getAccountAssetIdAt(accountId, index) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return get_account_asset_id_at_1.default(this, accountId, index); | ||
}); | ||
} | ||
isApprovedAccount(assetId, accountId) { | ||
@@ -92,0 +104,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -5,16 +5,19 @@ "use strict"; | ||
function getInterfaceCode(capability) { | ||
switch (capability) { | ||
case scaffold_1.AssetLedgerCapability.DESTROY_ASSET: | ||
return '0x9d118770'; | ||
case scaffold_1.AssetLedgerCapability.REVOKE_ASSET: | ||
return '0x20c5429b'; | ||
case scaffold_1.AssetLedgerCapability.UPDATE_ASSET: | ||
return '0xbda0e852'; | ||
case scaffold_1.AssetLedgerCapability.TOGGLE_TRANSFERS: | ||
return '0xbedb86fb'; | ||
default: | ||
return null; | ||
if (capability == scaffold_1.AssetLedgerCapability.DESTROY_ASSET) { | ||
return '0x9d118770'; | ||
} | ||
else if (capability == scaffold_1.AssetLedgerCapability.REVOKE_ASSET) { | ||
return '0x20c5429b'; | ||
} | ||
else if (capability == scaffold_1.AssetLedgerCapability.UPDATE_ASSET) { | ||
return '0xbda0e852'; | ||
} | ||
else if (capability == scaffold_1.AssetLedgerCapability.TOGGLE_TRANSFERS) { | ||
return '0xbedb86fb'; | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
exports.getInterfaceCode = getInterfaceCode; | ||
//# sourceMappingURL=capabilities.js.map |
@@ -12,2 +12,3 @@ "use strict"; | ||
const ethereum_utils_1 = require("@0xcert/ethereum-utils"); | ||
const kitty_index_to_approved_1 = require("./kitty-index-to-approved"); | ||
const functionSignature = '0x081812fc'; | ||
@@ -30,3 +31,3 @@ const inputTypes = ['uint256']; | ||
catch (error) { | ||
return null; | ||
return kitty_index_to_approved_1.default(ledger, assetId); | ||
} | ||
@@ -33,0 +34,0 @@ }); |
@@ -27,2 +27,6 @@ "use strict"; | ||
spec.before((stage) => __awaiter(this, void 0, void 0, function* () { | ||
const accounts = yield stage.web3.eth.getAccounts(); | ||
stage.set('coinbase', accounts[0]); | ||
})); | ||
spec.before((stage) => __awaiter(this, void 0, void 0, function* () { | ||
const provider = stage.get('provider'); | ||
@@ -48,3 +52,20 @@ const ledgerId = stage.get('protocol').xcert.instance.options.address; | ||
})); | ||
spec.test('check crypto kitty fallback hack', (ctx) => __awaiter(this, void 0, void 0, function* () { | ||
const provider = ctx.get('provider'); | ||
const coinbase = ctx.get('coinbase'); | ||
const kittyHackAbi = [{ 'constant': true, 'inputs': [{ 'name': '', 'type': 'uint256' }], 'name': 'kittyIndexToApproved', 'outputs': [{ 'name': '', 'type': 'address' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': '_index', 'type': 'uint256' }, { 'name': '_owner', 'type': 'address' }], 'name': 'addToKittyIndex', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }]; | ||
const kittyHackBytecode = '0x608060405234801561001057600080fd5b50610160806100206000396000f30060806040526004361061004b5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663481af3d38114610050578063d3adfa8e14610091575b600080fd5b34801561005c57600080fd5b506100686004356100c4565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561009d57600080fd5b506100c260043573ffffffffffffffffffffffffffffffffffffffff602435166100ec565b005b60006020819052908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b600091825260208290526040909120805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff9092169190911790555600a165627a7a723058201ae7be4968e8a069a633e1dd4845d3951d3a0cb52f5d6d1eaabf44d32332b44f0029'; | ||
const kittyHashContract = new ctx.web3.eth.Contract(kittyHackAbi); | ||
let ledgerId; | ||
yield kittyHashContract.deploy({ data: kittyHackBytecode }) | ||
.send({ from: coinbase, gas: 1000000 }) | ||
.then((newContractInstance) => { | ||
ledgerId = newContractInstance.options.address; | ||
kittyHashContract.options.address = ledgerId; | ||
}); | ||
yield kittyHashContract.methods.addToKittyIndex('1', coinbase).send({ from: coinbase }); | ||
const ledger = new ledger_1.AssetLedger(provider, ledgerId); | ||
ctx.is(yield ledger.getApprovedAccount('1'), coinbase); | ||
})); | ||
exports.default = spec; | ||
//# sourceMappingURL=get-approved-account-instance-method.test.js.map |
{ | ||
"files": {}, | ||
"files": { | ||
"packages/0xcert-ethereum-asset-ledger/README.md": "7f751a931986bff784f467ec1ebb152fe52927b9", | ||
"packages/0xcert-ethereum-asset-ledger/nodemon.json": "82b893373db9861f1df4b55d8ea68a5d37b118de", | ||
"packages/0xcert-ethereum-asset-ledger/package.json": "4114c2cc0daf886899a97d0fb9206c4c42800b6d", | ||
"packages/0xcert-ethereum-asset-ledger/src/core/ledger.ts": "f5bfd0846d8f8c5aa634353789ce9a4f539638bf", | ||
"packages/0xcert-ethereum-asset-ledger/src/index.ts": "4eade2f70adf9a014f7731f6bbd75e4ef33ad654", | ||
"packages/0xcert-ethereum-asset-ledger/src/lib/capabilities.ts": "b2b5cac4e71a808dcd945e48c02704e3661106eb", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/approve-account.ts": "2d5435d94cabc9de8da70c8370191c93d47cbaff", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/create-asset.ts": "f9e3caa8711c88dda062aecdfb91e320adf59292", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/deploy.ts": "761ffd14c70fc1ab3844de14fca617671283b66f", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/destroy-asset.ts": "178d0e4983018441098620ab90b3e30752858144", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/grant-abilities.ts": "325ade3ba0dea51f896c83f4061b6a22ced2eeeb", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/revoke-abilities.ts": "c5adcc4342791a640aba95e40a57d4584ace7b35", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/revoke-asset.ts": "97d1f74b8497abd26300d3b6009e78dbd2a67a0d", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/safe-transfer.ts": "d48dd52bf82781e9f945b97f30858d22c3ff4fd0", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/set-approval-for-all.ts": "669750eb14fe5b2347ff81d4028098f69c770050", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/set-enabled.ts": "e3815af250f795509f8e03c798bd89ced6531b4d", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/transfer.ts": "75d6f494974d244cd775b6fbf73c39bd05232325", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/update-asset.ts": "95d2d6460eb32dbe2a655dd136376215b4e0853b", | ||
"packages/0xcert-ethereum-asset-ledger/src/mutations/update.ts": "f6ea92d3c6d94f2661c8904c5098655775244ebd", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/get-abilities.ts": "216edc00ec724cff0ec369640c9baf0f9240c3bc", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/get-account-asset-id-at.ts": "01976a25f61456b99670a1804a24dfd30f422ebe", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/get-approved-account.ts": "c8a8db67c9868c88c1ce9fed90bebee9aa5a2770", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/get-asset-account.ts": "437c94da5b78a00cf4388f7992d42e1bf0252da1", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/get-asset-id-at.ts": "7a236e93e3b38c19841195fbdda98bae5bd0d48d", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/get-asset.ts": "311544c3aeeee8cddfdc3241eb71c16e61e77931", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/get-balance.ts": "d810422427d786a717df7642fd95968477c19311", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/get-capabilities.ts": "0b4bf51720c446789e2dfe6f6f5d7d2126d5ea6d", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/get-info.ts": "e1e5098e7cbb921edaf8e926ab9c1b7f10f01e8d", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/is-approved-for-all.ts": "a254c58912ab5e0672de4d4771e63bfd0ff29861", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/is-enabled.ts": "886ec17ab4d8ae71b36e53c17a6363006fee2173", | ||
"packages/0xcert-ethereum-asset-ledger/src/queries/kitty-index-to-approved.ts": "289ff63572cac30f91f1be6e9b8b85bccfe05a41", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/approve-account-instance-method.test.ts": "020536a6486c349fbc2520fadd11fb0c067d11a1", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/approve-operator-instance-method.test.ts": "e89e7c3fd19a689b165ebe6ae7be2e531b5d74d6", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/create-asset-instance-method.test.ts": "4d8e60bc198f2b170806214f41a4205e65da752a", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/deploy-static-method.test.ts": "676ff48823a5f5d395832949c91eff1f04b4a97b", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/destroy-asset-instance-method.test.ts": "1c7f3cfc05d4ea08d5481e2b30b404629a8f24f7", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/disapprove-account-instance-method.test.ts": "01d7b9f16010d757198af7520a82008275b7f60d", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/disapprove-operator-instance-method.test.ts": "2bfb3f935ce87730408e726fda01395f94433919", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-abilities-instance-method.test.ts": "8e9e4f0f4e9787d9b363647765812f02600c4421", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-account-asset-id-at-method.test.ts": "7738adfe12e4b67df7312eebb1153e414bda90a2", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-approved-account-instance-method.test.ts": "46d3c0f49425365c94c948f2a003d80893114aa9", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-asset-account-instance-method.test.ts": "4bc890208a87cadc10b72ad4686d20a24389203d", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-asset-id-at-method.test.ts": "1f64e5c15be58d969eee7bafd68b730d10a6617d", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-asset-instance-method.test.ts": "deef0ae4a7dc84f3a9bb2834cc629182f617aa58", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-balance-instance-method.test.ts": "5ef7ae2bbeb2f6b61e53842e4975367dc7664ee9", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-capabilities-instance-method.test.ts": "4332b91a470c0b8d54c9b7a8cb8b47e3553c8811", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-info-instance-method.test.ts": "146c34ec894b1f35121e7816bc6032e9b7ac0bfd", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/get-transfer-state-instance-method.test.ts": "9e6ba933cbbb784003451674828cd2db213564a6", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/grant-abilities-instance-method.test.ts": "fd7857517e5645f0713dc83e50afa08f0be595ef", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/is-approved-account-instance-method.test.ts": "53209ba6502dd06210e2dd0fb0296ca40ce25311", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/is-approved-operator-instance-method.test.ts": "5d25dcc71d51b9975e384c5de5bcdd2822d5b73b", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/revoke-abilities-instance-method.test.ts": "0f16d970750888f0590b700a9d64afcc504ff56a", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/revoke-asset-instance-method.test.ts": "579fdcf0b071eaa31a99fb724685896801754a5d", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/set-transfer-state-instance-method.test.ts": "af29338d905287fb1cec79613529f0902bb79287", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/transfer-asset-instance-method.test.ts": "bcd506777f3f5746bc10457b35d3da481555f00f", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/update-asset-instance-method.test.ts": "5739b4735f213cb2b98c066a24dca505737a2a52", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/core/ledger/update-instance-method.test.ts": "268402e1c3513b3599a0321e4c3ee205b180f930", | ||
"packages/0xcert-ethereum-asset-ledger/src/tests/index.test.ts": "46b17edb64e65254c5274bfb64a93a421d503b94", | ||
"packages/0xcert-ethereum-asset-ledger/tsconfig.json": "4aeac3c20e45b7e477e82012eb7788f7dbb11bf3", | ||
"packages/0xcert-ethereum-asset-ledger/tslint.json": "c57b3f0cdb7aa74ab2ab02888380f613589cbe66", | ||
"common/config/rush/npm-shrinkwrap.json": "b56bf5d9342bdd909289a88c77e60988dcde36a8" | ||
}, | ||
"arguments": "npm run lint && npx nyc npx specron test " | ||
} |
{ | ||
"name": "@0xcert/ethereum-asset-ledger", | ||
"version": "1.0.0-rc1", | ||
"version": "1.0.0-rc10", | ||
"description": "Asset ledger module for asset management on the Ethereum blockchain.", | ||
@@ -70,6 +70,6 @@ "main": "./dist/index.js", | ||
"devDependencies": { | ||
"@0xcert/ethereum-sandbox": "1.0.0-rc1", | ||
"@0xcert/ethereum-order-gateway": "1.0.0-rc1", | ||
"@specron/cli": "^0.5.1", | ||
"@specron/spec": "^0.5.1", | ||
"@0xcert/ethereum-sandbox": "1.0.0-rc10", | ||
"@0xcert/ethereum-order-gateway": "1.0.0-rc10", | ||
"@specron/cli": "^0.5.6", | ||
"@specron/spec": "^0.5.6", | ||
"nyc": "^13.1.0", | ||
@@ -80,10 +80,10 @@ "solc": "0.5.1", | ||
"typescript": "^3.1.1", | ||
"web3": "^1.0.0-beta.36" | ||
"web3": "1.0.0-beta.36" | ||
}, | ||
"dependencies": { | ||
"@0xcert/ethereum-generic-provider": "1.0.0-rc1", | ||
"@0xcert/ethereum-utils": "1.0.0-rc1", | ||
"@0xcert/scaffold": "1.0.0-rc1", | ||
"@0xcert/utils": "1.0.0-rc1" | ||
"@0xcert/ethereum-generic-provider": "1.0.0-rc10", | ||
"@0xcert/ethereum-utils": "1.0.0-rc10", | ||
"@0xcert/scaffold": "1.0.0-rc10", | ||
"@0xcert/utils": "1.0.0-rc10" | ||
} | ||
} |
@@ -21,5 +21,7 @@ import { GenericProvider, Mutation } from '@0xcert/ethereum-generic-provider'; | ||
import getAbilities from '../queries/get-abilities'; | ||
import getAccountAssetIdAt from '../queries/get-account-asset-id-at'; | ||
import getApprovedAccount from '../queries/get-approved-account'; | ||
import getAsset from '../queries/get-asset'; | ||
import getAssetAccount from '../queries/get-asset-account'; | ||
import getAssetIdAt from '../queries/get-asset-id-at'; | ||
import getBalance from '../queries/get-balance'; | ||
@@ -35,6 +37,14 @@ import getCapabilities from '../queries/get-capabilities'; | ||
export class AssetLedger implements AssetLedgerBase { | ||
protected $id: string; | ||
protected $provider: GenericProvider; | ||
/** | ||
* AssetLedger Id. Address pointing at the smartcontract. | ||
*/ | ||
protected _id: string; | ||
/** | ||
* Provider instance. | ||
*/ | ||
protected _provider: GenericProvider; | ||
/** | ||
* Deploys a new smart contract representing asset ledger to the blockchain. | ||
@@ -63,4 +73,4 @@ * @param provider Provider class with which we comunicate with blockchain. | ||
public constructor(provider: GenericProvider, id: string) { | ||
this.$id = normalizeAddress(id); | ||
this.$provider = provider; | ||
this._id = normalizeAddress(id); | ||
this._provider = provider; | ||
} | ||
@@ -72,3 +82,3 @@ | ||
public get id(): string { | ||
return this.$id; | ||
return this._id; | ||
} | ||
@@ -80,3 +90,3 @@ | ||
public get provider(): GenericProvider { | ||
return this.$provider; | ||
return this._provider; | ||
} | ||
@@ -139,2 +149,19 @@ | ||
/** | ||
* Gets the ID of the asset at index. | ||
* @param index Asset index. | ||
*/ | ||
public async getAssetIdAt(index: number): Promise<number> { | ||
return getAssetIdAt(this, index); | ||
} | ||
/** | ||
* Gets the ID of the asset at index for account. | ||
* @param accountId Account address. | ||
* @param index Asset index. | ||
*/ | ||
public async getAccountAssetIdAt(accountId: string, index: number): Promise<number> { | ||
return getAccountAssetIdAt(this, accountId, index); | ||
} | ||
/** | ||
* Checks if a specific account is approved for a specific asset. | ||
@@ -141,0 +168,0 @@ * @param assetId Id of the asset. |
@@ -8,14 +8,13 @@ import { AssetLedgerCapability } from '@0xcert/scaffold'; | ||
export function getInterfaceCode(capability: AssetLedgerCapability): string { | ||
switch (capability) { | ||
case AssetLedgerCapability.DESTROY_ASSET: | ||
return '0x9d118770'; | ||
case AssetLedgerCapability.REVOKE_ASSET: | ||
return '0x20c5429b'; | ||
case AssetLedgerCapability.UPDATE_ASSET: | ||
if (capability == AssetLedgerCapability.DESTROY_ASSET) { | ||
return '0x9d118770'; | ||
} else if (capability == AssetLedgerCapability.REVOKE_ASSET) { | ||
return '0x20c5429b'; | ||
} else if (capability == AssetLedgerCapability.UPDATE_ASSET) { | ||
return '0xbda0e852'; | ||
case AssetLedgerCapability.TOGGLE_TRANSFERS: | ||
return '0xbedb86fb'; | ||
default: | ||
return null; | ||
} | ||
} else if (capability == AssetLedgerCapability.TOGGLE_TRANSFERS) { | ||
return '0xbedb86fb'; | ||
} else { | ||
return null; | ||
} | ||
} |
import { decodeParameters, encodeParameters } from '@0xcert/ethereum-utils'; | ||
import { AssetLedger } from '../core/ledger'; | ||
import kittyIndexToApproved from './kitty-index-to-approved'; | ||
@@ -25,4 +26,4 @@ const functionSignature = '0x081812fc'; | ||
} catch (error) { | ||
return null; | ||
return kittyIndexToApproved(ledger, assetId); | ||
} | ||
} |
@@ -25,2 +25,7 @@ import { GenericProvider } from '@0xcert/ethereum-generic-provider'; | ||
spec.before(async (stage) => { | ||
const accounts = await stage.web3.eth.getAccounts(); | ||
stage.set('coinbase', accounts[0]); | ||
}); | ||
spec.before(async (stage) => { | ||
const provider = stage.get('provider'); | ||
@@ -49,2 +54,41 @@ const ledgerId = stage.get('protocol').xcert.instance.options.address; | ||
spec.test('check crypto kitty fallback hack', async (ctx) => { | ||
const provider = ctx.get('provider'); | ||
const coinbase = ctx.get('coinbase'); | ||
/** | ||
* To test kitty fallback we use a contract specially created for this: | ||
* pragma solidity ^0.4.24; | ||
* | ||
* contract KittyHackTest { | ||
* mapping (uint256 => address) public kittyIndexToApproved; | ||
* | ||
* function addToKittyIndex( | ||
* uint256 _index, | ||
* address _owner | ||
* ) | ||
* external | ||
* { | ||
* kittyIndexToApproved[_index] = _owner; | ||
* } | ||
* } | ||
*/ | ||
const kittyHackAbi = [{'constant': true, 'inputs': [{'name': '', 'type': 'uint256'}], 'name': 'kittyIndexToApproved', 'outputs': [{'name': '', 'type': 'address'}], 'payable': false, 'stateMutability': 'view', 'type': 'function'}, {'constant': false, 'inputs': [{'name': '_index', 'type': 'uint256'}, {'name': '_owner', 'type': 'address'}], 'name': 'addToKittyIndex', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function'}]; | ||
const kittyHackBytecode = '0x608060405234801561001057600080fd5b50610160806100206000396000f30060806040526004361061004b5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663481af3d38114610050578063d3adfa8e14610091575b600080fd5b34801561005c57600080fd5b506100686004356100c4565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561009d57600080fd5b506100c260043573ffffffffffffffffffffffffffffffffffffffff602435166100ec565b005b60006020819052908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b600091825260208290526040909120805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff9092169190911790555600a165627a7a723058201ae7be4968e8a069a633e1dd4845d3951d3a0cb52f5d6d1eaabf44d32332b44f0029'; | ||
const kittyHashContract = new ctx.web3.eth.Contract(kittyHackAbi); | ||
let ledgerId; | ||
await kittyHashContract.deploy({ data: kittyHackBytecode }) | ||
.send({ from: coinbase, gas: 1000000 }) | ||
.then((newContractInstance) => { | ||
ledgerId = newContractInstance.options.address; // instance with the new contract address | ||
kittyHashContract.options.address = ledgerId; | ||
}); | ||
await kittyHashContract.methods.addToKittyIndex('1', coinbase).send({ from: coinbase }); | ||
const ledger = new AssetLedger(provider, ledgerId); | ||
ctx.is(await ledger.getApprovedAccount('1'), coinbase); | ||
}); | ||
export default spec; |
@@ -239,11 +239,2 @@ { | ||
"ban-ts-ignore": true, | ||
"no-console": [ | ||
true, | ||
"log", | ||
"debug", | ||
"info", | ||
"time", | ||
"timeEnd", | ||
"trace" | ||
], | ||
"no-debugger": true, | ||
@@ -250,0 +241,0 @@ "no-eval": true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
506014
228
5632
+ Added@0xcert/ethereum-generic-provider@1.0.0-rc10(transitive)
+ Added@0xcert/ethereum-utils@1.0.0-rc10(transitive)
+ Added@0xcert/scaffold@1.0.0-rc10(transitive)
+ Added@0xcert/utils@1.0.0-rc10(transitive)
+ Addedevents@3.3.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removed@0xcert/ethereum-generic-provider@1.0.0-rc1(transitive)
- Removed@0xcert/ethereum-utils@1.0.0-rc1(transitive)
- Removed@0xcert/scaffold@1.0.0-rc1(transitive)
- Removed@0xcert/utils@1.0.0-rc1(transitive)
Updated@0xcert/scaffold@1.0.0-rc10
Updated@0xcert/utils@1.0.0-rc10