Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement suggested params #72

Merged
merged 27 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4521884
enable user to specify fee when getting transactions for the split co…
mjiang102628 Jan 23, 2020
6e00763
Update template.py
mjiang102628 Jan 23, 2020
6e0e021
Update template.py
mjiang102628 Jan 23, 2020
8ad2483
Merge branch 'develop' into michelle/split
mjiang102628 Jan 30, 2020
1345c16
Update test_unit.py
mjiang102628 Jan 30, 2020
3234f89
fix ratio implementation
mjiang102628 Feb 5, 2020
333fa1e
merge from develop
mjiang102628 Feb 5, 2020
b3efcbf
flip order of rat_1 and rat_2, use new golden
mjiang102628 Feb 5, 2020
0121530
add get_transaction for HTLC
mjiang102628 Feb 5, 2020
6930a7e
read receiver from contract in HTLC
mjiang102628 Feb 5, 2020
09ea8d0
Update test_unit.py
mjiang102628 Feb 5, 2020
e6a5f8f
Update test_unit.py
mjiang102628 Feb 5, 2020
f76c971
fix encoding bug
mjiang102628 Feb 5, 2020
2387417
add check for preimage matching hash image
mjiang102628 Feb 7, 2020
4bbf251
Update template.py
mjiang102628 Feb 11, 2020
7d821bb
implement txn params
mjiang102628 Feb 12, 2020
a6155a7
fix checks for override values
mjiang102628 Feb 12, 2020
51fadd3
update docstrings to allow None for params argument
mjiang102628 Feb 12, 2020
7a8984c
add SuggestedParams class
mjiang102628 Feb 19, 2020
f2ae305
Update transaction.py
mjiang102628 Feb 20, 2020
6349ba9
merge from develop
mjiang102628 Feb 20, 2020
5b6dbb6
pep8 compliance and extra check during encoding
mjiang102628 Feb 21, 2020
d6cc1b9
make genesisID optional
mjiang102628 Feb 25, 2020
4c4b487
Update transaction.py
mjiang102628 Feb 25, 2020
351dc48
Update template.py
mjiang102628 Feb 25, 2020
d8988e4
Update algod.py
mjiang102628 Feb 25, 2020
2238c7c
Update test_unit.py
mjiang102628 Feb 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
flip order of rat_1 and rat_2, use new golden
  • Loading branch information
mjiang102628 committed Feb 5, 2020
commit b3efcbfc0dfa47c94d93ecd71ba462e9c1c17889
12 changes: 6 additions & 6 deletions algosdk/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def get_program(self):
"EDMACCEFCzMBCCEGCxIQMwAIIQcPEBA=")
orig = base64.b64decode(orig)
offsets = [4, 7, 8, 9, 10, 14, 47, 80]
values = [self.max_fee, self.expiry_round, self.rat_1,
self.rat_2, self.min_pay, self.owner,
values = [self.max_fee, self.expiry_round, self.rat_2,
self.rat_1, self.min_pay, self.owner,
self.receiver_1, self.receiver_2]
types = [int, int, int, int, int, "address", "address", "address"]
return inject(orig, offsets, values, types)
Expand All @@ -88,11 +88,11 @@ def get_split_funds_transaction(contract, amount: int, fee: int, first_valid,
_, ints, bytearrays = logic.read_program(contract)
if not (len(ints) == 8 and len(bytearrays) == 3):
raise error.WrongContractError("split")
rat_1 = ints[5]
rat_2 = ints[6]
rat_1 = ints[6]
rat_2 = ints[5]
min_pay = ints[7]
receiver_1 = encoding.encode_address(bytearrays[0])
receiver_2 = encoding.encode_address(bytearrays[1])
receiver_1 = encoding.encode_address(bytearrays[1])
receiver_2 = encoding.encode_address(bytearrays[2])

amt_1 = 0
amt_2 = 0
Expand Down
37 changes: 30 additions & 7 deletions test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def test_group_id(self):

class TestMnemonic(unittest.TestCase):
def test_mnemonic_private_key(self):
priv_key, address = account.generate_account()
priv_key, _ = account.generate_account()
mn = mnemonic.from_private_key(priv_key)
self.assertEqual(len(mn.split(" ")), constants.mnemonic_len)
self.assertEqual(priv_key, mnemonic.to_private_key(mn))
Expand Down Expand Up @@ -723,7 +723,7 @@ def test_errors(self):

# get random private key
private_key_1, account_1 = account.generate_account()
private_key_2, account_2 = account.generate_account()
_, account_2 = account.generate_account()
private_key_3, account_3 = account.generate_account()

# create transaction
Expand Down Expand Up @@ -1178,17 +1178,40 @@ def test_split(self):
addr2 = "W6UUUSEAOGLBHT7VFT4H2SDATKKSG6ZBUIJXTZMSLW36YS44FRP5NVAU7U"
addr3 = "XCIBIN7RT4ZXGBMVAMU3QS6L5EKB7XGROC5EPCNHHYXUIBAA5Q6C5Y7NEU"
s = template.Split(addr1, addr2, addr3, 30, 100, 123456, 10000, 5000000)
golden = ("ASAIAcCWsQICAMDEBx5kkE4mAyCztwQn0+DycN+vsk+vJWcsoz/b7NDS" +
golden = ("ASAIAcCWsQICAMDEB2QekE4mAyCztwQn0+DycN+vsk+vJWcsoz/b7NDS" +
"6i33HOkvTpf+YiC3qUpIgHGWE8/1LPh9SGCalSN7IaITeeWSXbfsS5ws" +
"XyC4kBQ38Z8zcwWVAym4S8vpFB/c0XC6R4mnPi9EBADsPDEQIhIxASMM" +
"EDIEJBJAABkxCSgSMQcyAxIQMQglEhAxAiEEDRAiQAAuMwAAMwEAEjEJ" +
"MgMSEDMABykSEDMBByoSEDMACCEFCzMBCCEGCxIQMwAIIQcPEBA=")
golden_addr = "KPYGWKTV7CKMPMTLQRNGMEQRSYTYDHUOFNV4UDSBDLC44CLIJPQWRTCPBU"
golden_addr = "HDY7A4VHBWQWQZJBEMASFOUZKBNGWBMJEMUXAGZ4SPIRQ6C24MJHUZKFGY"
self.assertEqual(s.get_program(), base64.b64decode(golden))
self.assertEqual(s.get_address(), golden_addr)
txns = s.get_split_funds_transaction(s.get_program(), 130000, 10, 1234, 2234,
"f4OxZX/x/FO5LcGBSKHWXf" +
"wtSx+j1ncoSt3SABJtkGk=")
txns = s.get_split_funds_transaction(
s.get_program(), 1300000, 10000, 1, 100,
"f4OxZX/x/FO5LcGBSKHWX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D1YTogvvDXbqJsdmSjcmN2xCC4kBQ38Z8z" +
"cwWVAym4S8vpFB/c0XC6R4mnPi9EBADsPKNzbmTEIDjx8HKnDaFoZSEjASK6mV" +
"BaawWJIylwGzyT0Rh4WuMSpHR5cGWjcGF5")
encoded_txns = b''
for txn in txns:
encoded_txns += base64.b64decode(encoding.msgpack_encode(txn))
self.assertEqual(encoded_txns, golden_txns)

def test_HTLC(self):
addr1 = "726KBOYUJJNE5J5UHCSGQGWIBZWKCBN4WYD7YVSTEXEVNFPWUIJ7TAEOPM"
Expand Down