Skip to content

Commit

Permalink
feat: handle dcl known functions in @radspec helper
Browse files Browse the repository at this point in the history
  • Loading branch information
sohkai committed Jan 23, 2020
1 parent f31674f commit 0caa3a8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/data/decentraland/knownFunctions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export default {
'setOwner(address)': 'Set `$1` as the new owner',
'setOwner(bytes32,address)': 'Set `$2` as the new owner of the `$1` node',
'transfer(address,uint256)': 'Transfer `@tokenAmount(self, $2)` to `$1`',
'payday()': 'Get owed Payroll allowance',
'setOwnerCutPerMillion(uint256)': 'Set marketplace fees to `$1 / 1000000`%',
'transferMarketplaceOwnership(address)':
'Transfer ownership of the marketplace to `$1`',
Expand Down
7 changes: 7 additions & 0 deletions src/data/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import dclKnownFunctions from './decentraland/knownFunctions'
import baseKnownFunctions from './knownFunctions'

export const knownFunctions = {
...dclKnownFunctions,
...baseKnownFunctions
}
2 changes: 1 addition & 1 deletion src/helpers/radspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ABI from 'web3-eth-abi'
import { keccak256 } from 'web3-utils'
import MethodRegistry from './lib/methodRegistry'
import { evaluateRaw } from '../lib/'
import knownFunctions from '../data/knownFunctions'
import { knownFunctions } from '../data/'

const makeUnknownFunctionNode = (methodId) => ({
type: 'string',
Expand Down
7 changes: 7 additions & 0 deletions test/examples/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ const dataDecodeCases = [
data: bytes('0x6881385b') // payday(), on knownFunctions
}
}, 'Payroll: Get owed Payroll allowance!'],
[{
source: 'Decentraland: `@radspec(addr, data)`',
bindings: {
addr: address(),
data: bytes('0x1206dc5f00000000000000000000000031ab1f92344e3277ce9404e4e097dab7514e6d27') // transferMarketplaceOwnership(), on decentraland's knownFunctions
}
}, 'Decentraland: Transfer ownership of the marketplace to 0x31AB1f92344e3277ce9404E4e097dab7514E6D27'],
[{
source: 'Transfer: `@radspec(addr, data)`',
bindings: {
Expand Down

0 comments on commit 0caa3a8

Please sign in to comment.