algo/cleanup: cleanup

This commit is contained in:
Josh Siegel 2022-09-27 05:44:29 -05:00 committed by jumpsiegel
parent c5d2f9d54d
commit 77763d94dd
6 changed files with 179 additions and 47 deletions

View File

@ -10,6 +10,6 @@ artifacts:
@echo "Building artifacts for algorand" @echo "Building artifacts for algorand"
DOCKER_BUILDKIT=1 docker build -f Dockerfile.build -t algorand-builder -o type=local,dest=$@ . DOCKER_BUILDKIT=1 docker build -f Dockerfile.build -t algorand-builder -o type=local,dest=$@ .
../scripts/contract-upgrade-governance.sh -m token_bridge -c algorand -a `cat artifacts/token_approve.teal.hash` -o artifacts ../scripts/contract-upgrade-governance.sh -m token_bridge -c algorand -a `cat artifacts/token_approve.teal.hash` -o artifacts
../scripts/contract-upgrade-governance.sh -m core -c algorand -a `cat artifacts/core_approve.teal.hash` -o artifacts ../scripts/contract-upgrade-governance.sh -m core -c algorand -a `cat artifacts/core_approve.teal.hash` -o artifacts > artifacts/README.md

View File

@ -1312,12 +1312,27 @@ class PortalCore:
print("complete") print("complete")
def updateToken(self) -> None: def updateToken(self) -> None:
approval, clear = get_token_bridge(False, self.args.token_approve, self.args.token_clear, self.client, seed_amt=self.seed_amt, tmpl_sig=self.tsig, devMode = self.devnet or self.args.testnet) if self.args.approve == "" and self.args.clear == "":
approval, clear = get_token_bridge(False, self.args.token_approve, self.args.token_clear, self.client, seed_amt=self.seed_amt, tmpl_sig=self.tsig, devMode = self.devnet or self.args.testnet)
else:
pprint.pprint([self.args.approve, self.args.clear])
with open(self.args.approve, encoding = 'utf-8') as f:
approval = {"result": f.readlines()[0]}
pprint.pprint(approval)
with open(self.args.clear, encoding = 'utf-8') as f:
clear = {"result": f.readlines()[0]}
pprint.pprint(clear)
print("token " + decode_address(approval["hash"]).hex()) # print("token " + decode_address(approval["hash"]).hex())
print("Updating the token contracts: " + str(len(b64decode(approval["result"])))) print("Updating the token contracts: " + str(len(b64decode(approval["result"]))))
state = self.read_global_state(self.client, self.foundation.addr, self.tokenid)
pprint.pprint( {
"validUpdateApproveHash": b64decode(state["validUpdateApproveHash"]).hex(),
"validUpdateClearHash": b64decode(state["validUpdateClearHash"]).hex()
})
txn = transaction.ApplicationUpdateTxn( txn = transaction.ApplicationUpdateTxn(
index=self.tokenid, index=self.tokenid,
sender=self.foundation.getAddress(), sender=self.foundation.getAddress(),
@ -1375,7 +1390,7 @@ class PortalCore:
self.tokenid = 842126029 self.tokenid = 842126029
if self.args.coreid != 4: if self.args.coreid != 4:
self.coreid = self.args.coreid self.coreid = self.args.coreid
if self.args.coreid != 6: if self.args.tokenid != 6:
self.tokenid = self.args.tokenid self.tokenid = self.args.tokenid
def setup_args(self) -> None: def setup_args(self) -> None:
@ -1491,6 +1506,7 @@ class PortalCore:
if args.devnet and self.foundation == None: if args.devnet and self.foundation == None:
print("Generating the foundation account...") print("Generating the foundation account...")
self.foundation = self.getTemporaryAccount(self.client) self.foundation = self.getTemporaryAccount(self.client)
print("Foundation account: " + self.foundation.getMnemonic())
if self.args.fund: if self.args.fund:
sys.exit(0) sys.exit(0)

View File

@ -1,6 +1,6 @@
#pragma version 6 #pragma version 6
intcblock 1 0 127 2 1000 86400 128 255 intcblock 1 0 127 2 1000 86400 128 255
bytecblock 0x 0x0008 0x677561726469616e 0x63757272656e74477561726469616e536574496e646578 0x6e6f70 0x76657269667953696773 0x4d657373616765466565 0x76616c6964557064617465417070726f766548617368 0x767068617368 0x766572696679564141 0x50726f6772616d 0x7075626c6973684d657373616765 0x0001 0x0000000000000000000000000000000000000000000000000000000000000004 0x00000000000000000000000000000000000000000000000000000000436f7265 0x0000 0x626f6f746564 0x76616c6964557064617465436c65617248617368 0x6d657461 bytecblock 0x 0x0008 0x677561726469616e 0x63757272656e74477561726469616e536574496e646578 0x6e6f70 0x76657269667953696773 0x4d657373616765466565 0x76616c6964557064617465417070726f766548617368 0x767068617368 0x766572696679564141 0x7075626c6973684d657373616765 0x0001 0x0000000000000000000000000000000000000000000000000000000000000004 0x00000000000000000000000000000000000000000000000000000000436f7265 0x0000 0x626f6f746564 0x50726f6772616d 0x6d657461
txn ApplicationID txn ApplicationID
intc_1 // 0 intc_1 // 0
== ==
@ -24,7 +24,7 @@ bnz main_l6
err err
main_l6: main_l6:
txna ApplicationArgs 0 txna ApplicationArgs 0
bytec 11 // "publishMessage" bytec 10 // "publishMessage"
== ==
bnz main_l69 bnz main_l69
txna ApplicationArgs 0 txna ApplicationArgs 0
@ -150,7 +150,7 @@ txna ApplicationArgs 1
load 21 load 21
intc_3 // 2 intc_3 // 2
extract3 extract3
bytec 12 // 0x0001 bytec 11 // 0x0001
== ==
assert assert
txna ApplicationArgs 1 txna ApplicationArgs 1
@ -159,7 +159,7 @@ intc_3 // 2
+ +
pushint 32 // 32 pushint 32 // 32
extract3 extract3
bytec 13 // 0x0000000000000000000000000000000000000000000000000000000000000004 bytec 12 // 0x0000000000000000000000000000000000000000000000000000000000000004
== ==
assert assert
load 21 load 21
@ -170,7 +170,7 @@ txna ApplicationArgs 1
load 21 load 21
pushint 32 // 32 pushint 32 // 32
extract3 extract3
bytec 14 // 0x00000000000000000000000000000000000000000000000000000000436f7265 bytec 13 // 0x00000000000000000000000000000000000000000000000000000000436f7265
== ==
assert assert
load 21 load 21
@ -280,7 +280,7 @@ load 28
bytec_1 // 0x0008 bytec_1 // 0x0008
== ==
load 28 load 28
bytec 15 // 0x0000 bytec 14 // 0x0000
== ==
|| ||
assert assert
@ -701,12 +701,12 @@ txn Sender
global CreatorAddress global CreatorAddress
== ==
assert assert
bytec 16 // "booted" bytec 15 // "booted"
app_global_get app_global_get
intc_1 // 0 intc_1 // 0
== ==
assert assert
bytec 16 // "booted" bytec 15 // "booted"
pushbytes 0x74727565 // "true" pushbytes 0x74727565 // "true"
app_global_put app_global_put
callsub checkForDuplicate_11 callsub checkForDuplicate_11
@ -730,7 +730,7 @@ txna ApplicationArgs 1
load 2 load 2
intc_3 // 2 intc_3 // 2
extract3 extract3
bytec 12 // 0x0001 bytec 11 // 0x0001
== ==
assert assert
txna ApplicationArgs 1 txna ApplicationArgs 1
@ -739,7 +739,7 @@ intc_3 // 2
+ +
pushint 32 // 32 pushint 32 // 32
extract3 extract3
bytec 13 // 0x0000000000000000000000000000000000000000000000000000000000000004 bytec 12 // 0x0000000000000000000000000000000000000000000000000000000000000004
== ==
assert assert
load 2 load 2
@ -750,7 +750,7 @@ txna ApplicationArgs 1
load 2 load 2
pushint 32 // 32 pushint 32 // 32
extract3 extract3
bytec 14 // 0x00000000000000000000000000000000000000000000000000000000436f7265 bytec 13 // 0x00000000000000000000000000000000000000000000000000000000436f7265
== ==
assert assert
load 2 load 2
@ -858,7 +858,7 @@ load 9
bytec_1 // 0x0008 bytec_1 // 0x0008
== ==
load 9 load 9
bytec 15 // 0x0000 bytec 14 // 0x0000
== ==
|| ||
assert assert
@ -1004,7 +1004,7 @@ pop
load 0 load 0
log log
intc_0 // 1 intc_0 // 1
bytec 11 // "publishMessage" bytec 10 // "publishMessage"
callsub meta_5 callsub meta_5
intc_0 // 1 intc_0 // 1
return return
@ -1045,7 +1045,7 @@ main_l73:
intc_1 // 0 intc_1 // 0
return return
main_l74: main_l74:
bytec 10 // "Program" bytec 16 // "Program"
txn ApprovalProgram txn ApprovalProgram
concat concat
sha512_256 sha512_256
@ -1053,13 +1053,15 @@ bytec 7 // "validUpdateApproveHash"
app_global_get app_global_get
== ==
assert assert
bytec 10 // "Program"
txn ClearStateProgram txn ClearStateProgram
concat len
sha512_256 pushint 4 // 4
bytec 17 // "validUpdateClearHash"
app_global_get
== ==
txn ClearStateProgram
extract 1 3
pushbytes 0x810143 // 0x810143
==
&&
assert assert
intc_0 // 1 intc_0 // 1
return return
@ -1076,9 +1078,6 @@ app_global_put
bytec 7 // "validUpdateApproveHash" bytec 7 // "validUpdateApproveHash"
bytec_0 // "" bytec_0 // ""
app_global_put app_global_put
bytec 17 // "validUpdateClearHash"
pushbytes 0x73be5fd7cd378289177bf4a7ca5433ab30d91b417381bba8bd704aff2dec424f // 0x73be5fd7cd378289177bf4a7ca5433ab30d91b417381bba8bd704aff2dec424f
app_global_put
intc_0 // 1 intc_0 // 1
return return
@ -1218,7 +1217,7 @@ retsub
// meta // meta
meta_5: meta_5:
store 37 store 37
bytec 18 // "meta" bytec 17 // "meta"
load 37 load 37
app_local_put app_local_put
retsub retsub
@ -1226,7 +1225,7 @@ retsub
// checkMeta // checkMeta
checkMeta_6: checkMeta_6:
store 38 store 38
bytec 18 // "meta" bytec 17 // "meta"
app_local_get app_local_get
load 38 load 38
== ==
@ -1390,7 +1389,7 @@ retsub
getsigaddress_9: getsigaddress_9:
store 48 store 48
store 47 store 47
bytec 10 // "Program" bytec 16 // "Program"
pushbytes 0x0620010181 // 0x0620010181 pushbytes 0x0620010181 // 0x0620010181
concat concat
load 47 load 47

View File

@ -1,6 +1,6 @@
#pragma version 6 #pragma version 6
intcblock 0 1 2 127 133 128 255 intcblock 0 1 2 127 133 128 255
bytecblock 0x 0x636f72656964 0x436861696e 0x6e6174697665 0x7075626c6973684d657373616765 0x6e6f70 0x766572696679564141 0x0008 0x76616c6964557064617465417070726f766548617368 0x50726f6772616d 0x414c474f 0x76616c6964557064617465436c65617248617368 0x636f726541646472 bytecblock 0x 0x636f72656964 0x436861696e 0x6e6174697665 0x7075626c6973684d657373616765 0x6e6f70 0x766572696679564141 0x0008 0x76616c6964557064617465417070726f766548617368 0x414c474f 0x50726f6772616d 0x636f726541646472
txn ApplicationID txn ApplicationID
intc_0 // 0 intc_0 // 0
== ==
@ -1137,9 +1137,9 @@ b main_l63
main_l67: main_l67:
pushbytes 0x06 // 0x06 pushbytes 0x06 // 0x06
store 35 store 35
bytec 10 // "ALGO" bytec 9 // "ALGO"
store 36 store 36
bytec 10 // "ALGO" bytec 9 // "ALGO"
store 37 store 37
b main_l64 b main_l64
main_l68: main_l68:
@ -1509,7 +1509,7 @@ load 30
itxn_field ConfigAssetName itxn_field ConfigAssetName
load 29 load 29
itxn_field ConfigAssetUnitName itxn_field ConfigAssetUnitName
pushint 18446744073709551614 // 18446744073709551614 pushint 18446744073709550000 // 18446744073709550000
itxn_field ConfigAssetTotal itxn_field ConfigAssetTotal
load 28 load 28
itxn_field ConfigAssetDecimals itxn_field ConfigAssetDecimals
@ -1517,9 +1517,9 @@ global CurrentApplicationAddress
itxn_field ConfigAssetManager itxn_field ConfigAssetManager
txna Accounts 3 txna Accounts 3
itxn_field ConfigAssetReserve itxn_field ConfigAssetReserve
global ZeroAddress global CurrentApplicationAddress
itxn_field ConfigAssetFreeze itxn_field ConfigAssetFreeze
global ZeroAddress global CurrentApplicationAddress
itxn_field ConfigAssetClawback itxn_field ConfigAssetClawback
intc_0 // 0 intc_0 // 0
itxn_field Fee itxn_field Fee
@ -1555,7 +1555,7 @@ main_l79:
intc_0 // 0 intc_0 // 0
return return
main_l80: main_l80:
bytec 9 // "Program" bytec 10 // "Program"
txn ApprovalProgram txn ApprovalProgram
concat concat
sha512_256 sha512_256
@ -1563,13 +1563,15 @@ bytec 8 // "validUpdateApproveHash"
app_global_get app_global_get
== ==
assert assert
bytec 9 // "Program"
txn ClearStateProgram txn ClearStateProgram
concat len
sha512_256 pushint 4 // 4
bytec 11 // "validUpdateClearHash"
app_global_get
== ==
txn ClearStateProgram
extract 1 3
pushbytes 0x810143 // 0x810143
==
&&
assert assert
intc_1 // 1 intc_1 // 1
return return
@ -1578,15 +1580,12 @@ bytec_1 // "coreid"
txna ApplicationArgs 0 txna ApplicationArgs 0
btoi btoi
app_global_put app_global_put
bytec 12 // "coreAddr" bytec 11 // "coreAddr"
txna ApplicationArgs 1 txna ApplicationArgs 1
app_global_put app_global_put
bytec 8 // "validUpdateApproveHash" bytec 8 // "validUpdateApproveHash"
bytec_0 // "" bytec_0 // ""
app_global_put app_global_put
bytec 11 // "validUpdateClearHash"
pushbytes 0x73be5fd7cd378289177bf4a7ca5433ab30d91b417381bba8bd704aff2dec424f // 0x73be5fd7cd378289177bf4a7ca5433ab30d91b417381bba8bd704aff2dec424f
app_global_put
intc_1 // 1 intc_1 // 1
return return
@ -1942,7 +1941,7 @@ intc_0 // 0
bz sendMfee_11_l2 bz sendMfee_11_l2
intc_1 // pay intc_1 // pay
itxn_field TypeEnum itxn_field TypeEnum
bytec 12 // "coreAddr" bytec 11 // "coreAddr"
app_global_get app_global_get
itxn_field Receiver itxn_field Receiver
load 23 load 23
@ -2067,7 +2066,7 @@ retsub
getsigaddress_15: getsigaddress_15:
store 82 store 82
store 81 store 81
bytec 9 // "Program" bytec 10 // "Program"
pushbytes 0x0620010181 // 0x0620010181 pushbytes 0x0620010181 // 0x0620010181
concat concat
load 81 load 81

97
algorand/test/whinfo.ts Normal file
View File

@ -0,0 +1,97 @@
const algosdk = require("@certusone/wormhole-sdk/node_modules/algosdk");
import { calcLogicSigAccount } from "@certusone/wormhole-sdk/lib/cjs/algorand";
export async function getNativeAlgoAddress(
algoClient: any,
token_bridge: any,
assetId: any
) {
const { doesExist, lsa } = await calcLogicSigAccount(
algoClient,
BigInt(token_bridge),
BigInt(assetId),
Buffer.from("native", "binary").toString("hex")
);
return lsa.address();
}
async function firstTransaction() {
let algodToken;
let algodServer;
let algodPort;
let server;
let port;
let token;
let appid;
const mainnet = true;
if (mainnet) {
appid = 842126029;
algodToken = "";
algodServer = "https://mainnet-api.algonode.cloud";
algodPort = 443;
server = "https://mainnet-idx.algonode.cloud";
port = 443;
token = "";
} else {
appid = 6;
algodToken =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
algodServer = "http://localhost";
algodPort = 4001;
server = "http://localhost";
port = 8980;
token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
}
let algodClient = new algosdk.Algodv2(algodToken, algodServer, algodPort);
let indexerClient = new algosdk.Indexer(token, server, port);
let addr = algosdk.getApplicationAddress(appid); // mainnet token bridge account
let ret = await indexerClient
.searchAccounts()
.authAddr(addr)
.applicationID(appid)
.do();
let wormholeAssets: any = [];
let nativeAssets: any = [];
while (true) {
ret["accounts"].forEach((x: any) => {
let amt = x["amount"];
if (x["assets"] != undefined) {
x["assets"].forEach((a: any) => {
if (x["created-assets"] != undefined) {
wormholeAssets.push(a);
} else {
nativeAssets.push(a);
}
});
}
});
if (ret["next-token"] == undefined) {
break;
}
ret = await indexerClient
.searchAccounts()
.authAddr(addr)
.applicationID(appid)
.nextToken(ret["next-token"])
.do();
}
console.log("wormhole assets");
for (let i = 0; i < wormholeAssets.length; i++) {
let assetId = wormholeAssets[i]["asset-id"];
let assetInfo = await algodClient.getAssetByID(assetId).do();
let acctInfo = await algodClient.accountInformation(assetInfo["params"]["creator"]).do();
console.log(assetId, assetInfo, acctInfo);
}
}
firstTransaction();

View File

@ -293,6 +293,27 @@ def approve_token_bridge(seed_amt: int, tmpl_sig: TmplSig, devMode: bool):
Approve() Approve()
]) ])
# # This blows up an asset on algorand. This will be added temporarily (and then removed) to clean some stuff before we relaunch
# def killAsset():
# return Seq([
# MagicAssert(Txn.sender() == Global.creator_address()),
#
# blob.zero(Int(1)),
#
# InnerTxnBuilder.Begin(),
# InnerTxnBuilder.SetFields(
# {
# TxnField.sender: Global.current_application_address(),
# TxnField.type_enum: TxnType.AssetConfig,
# TxnField.config_asset: Btoi(Txn.application_args[1]),
# TxnField.fee: Int(0),
# }
# ),
# InnerTxnBuilder.Submit(),
#
# Approve()
# ])
def receiveAttest(): def receiveAttest():
me = Global.current_application_address() me = Global.current_application_address()