Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
offshiftXFT
protocol-main
Commits
286c7526
Commit
286c7526
authored
4 years ago
by
XFT-dev
Browse files
Options
Download
Email Patches
Plain Diff
adding scripts
parent
9313cadd
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1625 additions
and
0 deletions
+1625
-0
frontend/Shifting/README.md
frontend/Shifting/README.md
+2
-0
frontend/Shifting/scripts/js/index.js
frontend/Shifting/scripts/js/index.js
+115
-0
frontend/Shifting/scripts/js/package.json
frontend/Shifting/scripts/js/package.json
+14
-0
frontend/Shifting/scripts/js/shift-abi.json
frontend/Shifting/scripts/js/shift-abi.json
+66
-0
frontend/Shifting/scripts/js/token-abi.json
frontend/Shifting/scripts/js/token-abi.json
+640
-0
frontend/Shifting/scripts/py/requirements.txt
frontend/Shifting/scripts/py/requirements.txt
+1
-0
frontend/Shifting/scripts/py/script.py
frontend/Shifting/scripts/py/script.py
+81
-0
frontend/Shifting/scripts/py/shift-abi.json
frontend/Shifting/scripts/py/shift-abi.json
+66
-0
frontend/Shifting/scripts/py/token-abi.json
frontend/Shifting/scripts/py/token-abi.json
+640
-0
frontend/Shifting/website/Shift.html
frontend/Shifting/website/Shift.html
+0
-0
frontend/Shifting/website/faucet.html
frontend/Shifting/website/faucet.html
+0
-0
frontend/Shifting/website/mini.css
frontend/Shifting/website/mini.css
+0
-0
No files found.
frontend/Shifting/README.md
View file @
286c7526
# Shifting frontend
# Shifting frontend
website directory: browser based frontend (requires metamask for interaction).
scripts directory: scripts for interacting with the contracts.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/Shifting/scripts/js/index.js
0 → 100644
View file @
286c7526
const
Web3
=
require
(
"
web3
"
);
const
fs
=
require
(
'
fs
'
);
const
readline
=
require
(
"
readline
"
);
let
web3
=
new
Web3
(
Web3
.
givenProvider
||
"
ws://localhost:8545
"
)
let
shift_abi
=
fs
.
readFileSync
(
'
shift-abi.json
'
);
let
shift
=
new
web3
.
eth
.
Contract
(
JSON
.
parse
(
shift_abi
),
"
0x6bE4C94052BF34e09d67C255D9Fe564c5abd4f95
"
);
let
token_abi
=
fs
.
readFileSync
(
'
token-abi.json
'
);
let
tokenA
=
new
web3
.
eth
.
Contract
(
JSON
.
parse
(
token_abi
),
"
0x1190fb1B00D20656549cdFF689E55D072BA764f3
"
);
let
tokenB
=
new
web3
.
eth
.
Contract
(
JSON
.
parse
(
token_abi
),
"
0x0e1BFf82509994170026f47f1d0857fB275c3003
"
);
web3
.
eth
.
accounts
.
wallet
.
add
(
web3
.
eth
.
accounts
.
privateKeyToAccount
(
"
0x0
"
));
async
function
approve
(
num
)
{
let
amount
=
web3
.
utils
.
toWei
(
parseFloat
(
num
).
toString
(),
'
ether
'
);
const
gasPrice
=
await
web3
.
eth
.
getGasPrice
();
const
gasEstimate
=
await
tokenA
.
methods
.
approve
(
shift
.
_address
,
amount
).
estimateGas
({
from
:
web3
.
eth
.
accounts
.
wallet
[
0
].
address
});
if
(
amount
=>
0
)
{
let
approvalAmount
;
tokenA
.
methods
.
allowance
(
web3
.
eth
.
accounts
.
wallet
[
0
].
address
,
shift
.
_address
).
call
({
from
:
web3
.
eth
.
accounts
.
wallet
[
0
].
address
}).
then
(
data
=>
approvalAmount
=
data
);
if
(
approvalAmount
>=
amount
)
{
console
.
log
(
"
already approved
"
);
}
else
{
tokenA
.
methods
.
approve
(
shift
.
_address
,
amount
).
send
({
from
:
web3
.
eth
.
accounts
.
wallet
[
0
].
address
,
gasPrice
:
gasPrice
,
gas
:
gasEstimate
}).
then
(
console
.
log
);
}
}
else
{
console
.
log
(
"
input a number
"
);
}
await
sleep
(
20000
);
}
async
function
shifter
(
num
)
{
let
A_aggregator
=
"
0xECe365B379E1dD183B20fc5f022230C044d51404
"
;
let
B_aggregator
=
"
0xab4a352ac35dFE83221220D967Db41ee61A0DeFa
"
;
let
amount
=
web3
.
utils
.
toWei
(
parseFloat
(
num
).
toString
(),
'
ether
'
);
const
gasPrice
=
await
web3
.
eth
.
getGasPrice
();
const
gasEstimate
=
await
shift
.
methods
.
shift
(
amount
,
A_aggregator
,
B_aggregator
).
estimateGas
({
from
:
web3
.
eth
.
accounts
.
wallet
[
0
].
address
});
if
(
amount
>
0
)
{
shift
.
methods
.
shift
(
amount
,
A_aggregator
,
B_aggregator
).
send
({
from
:
web3
.
eth
.
accounts
.
wallet
[
0
].
address
,
gasPrice
:
gasPrice
,
gas
:
gasEstimate
}).
then
(
console
.
log
);
}
}
async
function
faucet
()
{
const
gasPrice
=
await
web3
.
eth
.
getGasPrice
();
const
gasEstimate
=
await
shift
.
methods
.
faucet
().
estimateGas
({
from
:
web3
.
eth
.
accounts
.
wallet
[
0
].
address
});
shift
.
methods
.
faucet
().
send
({
from
:
web3
.
eth
.
accounts
.
wallet
[
0
].
address
,
gasPrice
:
gasPrice
,
gas
:
gasEstimate
}).
then
(
console
.
log
);
await
sleep
(
6000
);
}
function
sleep
(
ms
)
{
return
new
Promise
((
resolve
)
=>
{
setTimeout
(
resolve
,
ms
);
});
}
async
function
handle_shift
(
n
)
{
await
approve
(
n
);
await
shifter
(
n
);
}
async
function
handle_args
(
arg
)
{
switch
(
arg
)
{
case
"
0
"
:
await
faucet
();
break
;
case
"
1
"
:
rl
.
question
(
"
Amount of tokens to shift:
"
,
function
(
given_amount
)
{
handle_shift
(
given_amount
);
});
break
;
case
"
2
"
:
await
tokenA
.
methods
.
balanceOf
(
web3
.
eth
.
accounts
.
wallet
[
0
].
address
).
call
().
then
(
t
=>
console
.
log
(
`current xftTM
${
t
/
1
e18
}
`
));
break
;
case
"
3
"
:
await
tokenB
.
methods
.
balanceOf
(
web3
.
eth
.
accounts
.
wallet
[
0
].
address
).
call
().
then
(
t
=>
console
.
log
(
`current xftTB
${
t
/
1
e18
}
`
));
break
;
}
rl
.
close
();
}
const
rl
=
readline
.
createInterface
({
input
:
process
.
stdin
,
output
:
process
.
stdout
});
console
.
log
(
`
Request funds from the faucet -> 0
shift tokens -> 1
get xftTM balance -> 2
get xftTB balance -> 3
EXIT -> 4
`
);
rl
.
question
(
"
Please select an option:
"
,
function
(
option
)
{
switch
(
option
)
{
case
"
4
"
:
rl
.
close
();
default
:
handle_args
(
option
);
}
});
rl
.
on
(
"
close
"
,
function
()
{
console
.
log
(
"
\n
BYE -_-
"
);
process
.
exit
(
0
);
});
This diff is collapsed.
Click to expand it.
frontend/Shifting/scripts/js/package.json
0 → 100644
View file @
286c7526
{
"name"
:
"script"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"devDependencies"
:
{
"web3"
:
"^1.3.5"
}
}
This diff is collapsed.
Click to expand it.
frontend/Shifting/scripts/js/shift-abi.json
0 → 100644
View file @
286c7526
[
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"_tokenA"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"_tokenB"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"_chainlink"
,
"type"
:
"address"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"constructor"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
false
,
"internalType"
:
"uint256"
,
"name"
:
"value"
,
"type"
:
"uint256"
}
],
"name"
:
"Shifted"
,
"type"
:
"event"
},
{
"inputs"
:
[],
"name"
:
"faucet"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
},
{
"internalType"
:
"address"
,
"name"
:
"_A"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"_B"
,
"type"
:
"address"
}
],
"name"
:
"shift"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
}
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/Shifting/scripts/js/token-abi.json
0 → 100644
View file @
286c7526
[
{
"inputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"constructor"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"owner"
,
"type"
:
"address"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
},
{
"indexed"
:
false
,
"internalType"
:
"uint256"
,
"name"
:
"value"
,
"type"
:
"uint256"
}
],
"name"
:
"Approval"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
false
,
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"Paused"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"previousAdminRole"
,
"type"
:
"bytes32"
},
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"newAdminRole"
,
"type"
:
"bytes32"
}
],
"name"
:
"RoleAdminChanged"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"sender"
,
"type"
:
"address"
}
],
"name"
:
"RoleGranted"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"sender"
,
"type"
:
"address"
}
],
"name"
:
"RoleRevoked"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"from"
,
"type"
:
"address"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"to"
,
"type"
:
"address"
},
{
"indexed"
:
false
,
"internalType"
:
"uint256"
,
"name"
:
"value"
,
"type"
:
"uint256"
}
],
"name"
:
"Transfer"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
false
,
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"Unpaused"
,
"type"
:
"event"
},
{
"inputs"
:
[],
"name"
:
"BURNER_ROLE"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"DEFAULT_ADMIN_ROLE"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"MINTER_ROLE"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"PAUSER_ROLE"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"owner"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
}
],
"name"
:
"allowance"
,
"outputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
""
,
"type"
:
"uint256"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"approve"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"balanceOf"
,
"outputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
""
,
"type"
:
"uint256"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"burn"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"from"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"burn"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"burnFrom"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"decimals"
,
"outputs"
:
[
{
"internalType"
:
"uint8"
,
"name"
:
""
,
"type"
:
"uint8"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"subtractedValue"
,
"type"
:
"uint256"
}
],
"name"
:
"decreaseAllowance"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
}
],
"name"
:
"getRoleAdmin"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"grantRole"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"hasRole"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"addedValue"
,
"type"
:
"uint256"
}
],
"name"
:
"increaseAllowance"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"to"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"mint"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"name"
,
"outputs"
:
[
{
"internalType"
:
"string"
,
"name"
:
""
,
"type"
:
"string"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"pause"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"paused"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"renounceRole"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"revokeRole"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes4"
,
"name"
:
"interfaceId"
,
"type"
:
"bytes4"
}
],
"name"
:
"supportsInterface"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"symbol"
,
"outputs"
:
[
{
"internalType"
:
"string"
,
"name"
:
""
,
"type"
:
"string"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"totalSupply"
,
"outputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
""
,
"type"
:
"uint256"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"recipient"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"transfer"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"sender"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"recipient"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"transferFrom"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"unpause"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
}
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/Shifting/scripts/py/requirements.txt
0 → 100644
View file @
286c7526
web3==5.12.1
This diff is collapsed.
Click to expand it.
frontend/Shifting/scripts/py/script.py
0 → 100644
View file @
286c7526
from
web3.auto.infura.rinkeby
import
w3
import
json
with
open
(
"shift-abi.json"
,
"r"
)
as
f
:
shift_abi
=
json
.
load
(
f
)
with
open
(
"token-abi.json"
,
"r"
)
as
f
:
token_abi
=
json
.
load
(
f
)
priv_key
=
"0x0"
w3
.
eth
.
defaultAccount
=
w3
.
eth
.
account
.
privateKeyToAccount
(
priv_key
)
shift_contract
=
w3
.
eth
.
contract
(
abi
=
shift_abi
,
address
=
w3
.
toChecksumAddress
(
"0x6bE4C94052BF34e09d67C255D9Fe564c5abd4f95"
))
tokenA
=
w3
.
eth
.
contract
(
abi
=
token_abi
,
address
=
w3
.
toChecksumAddress
(
"0x1190fb1B00D20656549cdFF689E55D072BA764f3"
))
tokenB
=
w3
.
eth
.
contract
(
abi
=
token_abi
,
address
=
w3
.
toChecksumAddress
(
"0x0e1BFf82509994170026f47f1d0857fB275c3003"
))
def
approve
(
amount
):
txn
=
tokenA
.
functions
.
approve
(
shift_contract
.
address
,
int
(
amount
*
1e18
)).
buildTransaction
({
'chainId'
:
4
,
'gas'
:
500000
,
'gasPrice'
:
w3
.
eth
.
gasPrice
,
'nonce'
:
w3
.
eth
.
getTransactionCount
(
w3
.
eth
.
defaultAccount
.
address
)
})
signed_txn
=
w3
.
eth
.
account
.
signTransaction
(
txn
,
'0x047eb26808901c4fdf33262a3d9ea7e6a15f5683f9f60eef1b5a615fc2b3756a'
)
txn_hash
=
w3
.
eth
.
sendRawTransaction
(
signed_txn
.
rawTransaction
)
tx_receipt
=
w3
.
eth
.
waitForTransactionReceipt
(
txn_hash
)
def
shift
(
amount
):
A_aggregator
=
"0xECe365B379E1dD183B20fc5f022230C044d51404"
;
B_aggregator
=
"0xab4a352ac35dFE83221220D967Db41ee61A0DeFa"
;
txn
=
shift_contract
.
functions
.
shift
(
int
(
amount
*
1e18
),
A_aggregator
,
B_aggregator
).
buildTransaction
({
'chainId'
:
4
,
'gas'
:
500000
,
'gasPrice'
:
w3
.
eth
.
gasPrice
,
#w3.eth.gasPrice,
'nonce'
:
w3
.
eth
.
getTransactionCount
(
w3
.
eth
.
defaultAccount
.
address
)
})
signed_txn
=
w3
.
eth
.
account
.
signTransaction
(
txn
,
'0x047eb26808901c4fdf33262a3d9ea7e6a15f5683f9f60eef1b5a615fc2b3756a'
)
txn_hash
=
w3
.
eth
.
sendRawTransaction
(
signed_txn
.
rawTransaction
)
tx_receipt
=
w3
.
eth
.
waitForTransactionReceipt
(
txn_hash
)
def
faucet
():
txn
=
shift_contract
.
functions
.
faucet
().
buildTransaction
({
'chainId'
:
4
,
'gas'
:
500000
,
'gasPrice'
:
w3
.
eth
.
gasPrice
,
#w3.eth.gasPrice,
'nonce'
:
w3
.
eth
.
getTransactionCount
(
w3
.
eth
.
defaultAccount
.
address
)
})
signed_txn
=
w3
.
eth
.
account
.
signTransaction
(
txn
,
'0x047eb26808901c4fdf33262a3d9ea7e6a15f5683f9f60eef1b5a615fc2b3756a'
)
txn_hash
=
w3
.
eth
.
sendRawTransaction
(
signed_txn
.
rawTransaction
)
tx_receipt
=
w3
.
eth
.
waitForTransactionReceipt
(
txn_hash
)
def
take_input
():
t
=
input
(
"please select an option: "
)
if
t
==
"1"
:
n
=
input
(
"amount of tokens to shift: "
)
approve
(
int
(
n
))
shift
(
int
(
n
))
elif
t
==
"2"
:
print
(
"requesting funds"
)
faucet
()
print
(
"funds transfered :D"
)
elif
t
==
"3"
:
print
(
tokenA
.
functions
.
balanceOf
(
w3
.
eth
.
defaultAccount
.
address
).
call
({
'from'
:
w3
.
eth
.
defaultAccount
.
address
})
/
1e18
)
elif
t
==
"4"
:
print
(
tokenB
.
functions
.
balanceOf
(
w3
.
eth
.
defaultAccount
.
address
).
call
({
'from'
:
w3
.
eth
.
defaultAccount
.
address
})
/
1e18
)
elif
t
==
"0"
:
exit
(
0
);
else
:
print
(
"invalid option provided"
)
if
__name__
==
"__main__"
:
help_menu
=
"""
shift tokens: 1
request funds from the faucet: 2
check xftTM balance: 3
check xftTB balance: 4
exit : 0
"""
print
(
help_menu
)
while
True
:
take_input
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/Shifting/scripts/py/shift-abi.json
0 → 100644
View file @
286c7526
[
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"_tokenA"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"_tokenB"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"_chainlink"
,
"type"
:
"address"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"constructor"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
false
,
"internalType"
:
"uint256"
,
"name"
:
"value"
,
"type"
:
"uint256"
}
],
"name"
:
"Shifted"
,
"type"
:
"event"
},
{
"inputs"
:
[],
"name"
:
"faucet"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
},
{
"internalType"
:
"address"
,
"name"
:
"_A"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"_B"
,
"type"
:
"address"
}
],
"name"
:
"shift"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
}
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/Shifting/scripts/py/token-abi.json
0 → 100644
View file @
286c7526
[
{
"inputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"constructor"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"owner"
,
"type"
:
"address"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
},
{
"indexed"
:
false
,
"internalType"
:
"uint256"
,
"name"
:
"value"
,
"type"
:
"uint256"
}
],
"name"
:
"Approval"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
false
,
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"Paused"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"previousAdminRole"
,
"type"
:
"bytes32"
},
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"newAdminRole"
,
"type"
:
"bytes32"
}
],
"name"
:
"RoleAdminChanged"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"sender"
,
"type"
:
"address"
}
],
"name"
:
"RoleGranted"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"sender"
,
"type"
:
"address"
}
],
"name"
:
"RoleRevoked"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"from"
,
"type"
:
"address"
},
{
"indexed"
:
true
,
"internalType"
:
"address"
,
"name"
:
"to"
,
"type"
:
"address"
},
{
"indexed"
:
false
,
"internalType"
:
"uint256"
,
"name"
:
"value"
,
"type"
:
"uint256"
}
],
"name"
:
"Transfer"
,
"type"
:
"event"
},
{
"anonymous"
:
false
,
"inputs"
:
[
{
"indexed"
:
false
,
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"Unpaused"
,
"type"
:
"event"
},
{
"inputs"
:
[],
"name"
:
"BURNER_ROLE"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"DEFAULT_ADMIN_ROLE"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"MINTER_ROLE"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"PAUSER_ROLE"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"owner"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
}
],
"name"
:
"allowance"
,
"outputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
""
,
"type"
:
"uint256"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"approve"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"balanceOf"
,
"outputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
""
,
"type"
:
"uint256"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"burn"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"from"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"burn"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"burnFrom"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"decimals"
,
"outputs"
:
[
{
"internalType"
:
"uint8"
,
"name"
:
""
,
"type"
:
"uint8"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"subtractedValue"
,
"type"
:
"uint256"
}
],
"name"
:
"decreaseAllowance"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
}
],
"name"
:
"getRoleAdmin"
,
"outputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
""
,
"type"
:
"bytes32"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"grantRole"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"hasRole"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"spender"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"addedValue"
,
"type"
:
"uint256"
}
],
"name"
:
"increaseAllowance"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"to"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"mint"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"name"
,
"outputs"
:
[
{
"internalType"
:
"string"
,
"name"
:
""
,
"type"
:
"string"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"pause"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"paused"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"renounceRole"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes32"
,
"name"
:
"role"
,
"type"
:
"bytes32"
},
{
"internalType"
:
"address"
,
"name"
:
"account"
,
"type"
:
"address"
}
],
"name"
:
"revokeRole"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"bytes4"
,
"name"
:
"interfaceId"
,
"type"
:
"bytes4"
}
],
"name"
:
"supportsInterface"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"symbol"
,
"outputs"
:
[
{
"internalType"
:
"string"
,
"name"
:
""
,
"type"
:
"string"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"totalSupply"
,
"outputs"
:
[
{
"internalType"
:
"uint256"
,
"name"
:
""
,
"type"
:
"uint256"
}
],
"stateMutability"
:
"view"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"recipient"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"transfer"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[
{
"internalType"
:
"address"
,
"name"
:
"sender"
,
"type"
:
"address"
},
{
"internalType"
:
"address"
,
"name"
:
"recipient"
,
"type"
:
"address"
},
{
"internalType"
:
"uint256"
,
"name"
:
"amount"
,
"type"
:
"uint256"
}
],
"name"
:
"transferFrom"
,
"outputs"
:
[
{
"internalType"
:
"bool"
,
"name"
:
""
,
"type"
:
"bool"
}
],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
},
{
"inputs"
:
[],
"name"
:
"unpause"
,
"outputs"
:
[],
"stateMutability"
:
"nonpayable"
,
"type"
:
"function"
}
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/Shifting/Shift.html
→
frontend/Shifting/
website/
Shift.html
View file @
286c7526
File moved
This diff is collapsed.
Click to expand it.
frontend/Shifting/faucet.html
→
frontend/Shifting/
website/
faucet.html
View file @
286c7526
File moved
This diff is collapsed.
Click to expand it.
frontend/Shifting/mini.css
→
frontend/Shifting/
website/
mini.css
View file @
286c7526
File moved
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment