-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) Added logic in Composer to create the Tokenfactory related mes…
…sages to admin tokens. Added new example scripts for all the messages.
- Loading branch information
abel
committed
Jan 3, 2024
1 parent
4f14a69
commit e733927
Showing
8 changed files
with
448 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import asyncio | ||
|
||
from pyinjective.composer import Composer as ProtoMsgComposer | ||
from pyinjective.core.broadcaster import MsgBroadcasterWithPk | ||
from pyinjective.core.network import Network | ||
from pyinjective.wallet import PrivateKey | ||
|
||
|
||
async def main() -> None: | ||
# select network: local, testnet, mainnet | ||
network = Network.testnet() | ||
composer = ProtoMsgComposer(network=network.string()) | ||
private_key_in_hexa = "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3" | ||
|
||
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation( | ||
network=network, | ||
private_key=private_key_in_hexa, | ||
) | ||
|
||
priv_key = PrivateKey.from_hex(private_key_in_hexa) | ||
pub_key = priv_key.to_public_key() | ||
address = pub_key.to_address() | ||
|
||
message = composer.msg_create_denom( | ||
sender=address.to_acc_bech32(), subdenom="inj_test", name="Injective Test Token", symbol="INJTEST" | ||
) | ||
|
||
# broadcast the transaction | ||
result = await message_broadcaster.broadcast([message]) | ||
print("---Transaction Response---") | ||
print(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import asyncio | ||
|
||
from pyinjective.composer import Composer as ProtoMsgComposer | ||
from pyinjective.core.broadcaster import MsgBroadcasterWithPk | ||
from pyinjective.core.network import Network | ||
from pyinjective.wallet import PrivateKey | ||
|
||
|
||
async def main() -> None: | ||
# select network: local, testnet, mainnet | ||
network = Network.testnet() | ||
composer = ProtoMsgComposer(network=network.string()) | ||
private_key_in_hexa = "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3" | ||
|
||
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation( | ||
network=network, | ||
private_key=private_key_in_hexa, | ||
) | ||
|
||
priv_key = PrivateKey.from_hex(private_key_in_hexa) | ||
pub_key = priv_key.to_public_key() | ||
address = pub_key.to_address() | ||
|
||
amount = composer.Coin(amount=1_000_000_000, denom="factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test") | ||
|
||
message = composer.msg_mint( | ||
sender=address.to_acc_bech32(), | ||
amount=amount, | ||
) | ||
|
||
# broadcast the transaction | ||
result = await message_broadcaster.broadcast([message]) | ||
print("---Transaction Response---") | ||
print(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import asyncio | ||
|
||
from pyinjective.composer import Composer as ProtoMsgComposer | ||
from pyinjective.core.broadcaster import MsgBroadcasterWithPk | ||
from pyinjective.core.network import Network | ||
from pyinjective.wallet import PrivateKey | ||
|
||
|
||
async def main() -> None: | ||
# select network: local, testnet, mainnet | ||
network = Network.testnet() | ||
composer = ProtoMsgComposer(network=network.string()) | ||
private_key_in_hexa = "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3" | ||
|
||
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation( | ||
network=network, | ||
private_key=private_key_in_hexa, | ||
) | ||
|
||
priv_key = PrivateKey.from_hex(private_key_in_hexa) | ||
pub_key = priv_key.to_public_key() | ||
address = pub_key.to_address() | ||
|
||
amount = composer.Coin(amount=100, denom="factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test") | ||
|
||
message = composer.msg_burn( | ||
sender=address.to_acc_bech32(), | ||
amount=amount, | ||
) | ||
|
||
# broadcast the transaction | ||
result = await message_broadcaster.broadcast([message]) | ||
print("---Transaction Response---") | ||
print(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import asyncio | ||
|
||
from pyinjective.composer import Composer as ProtoMsgComposer | ||
from pyinjective.core.broadcaster import MsgBroadcasterWithPk | ||
from pyinjective.core.network import Network | ||
from pyinjective.wallet import PrivateKey | ||
|
||
|
||
async def main() -> None: | ||
# select network: local, testnet, mainnet | ||
network = Network.testnet() | ||
composer = ProtoMsgComposer(network=network.string()) | ||
private_key_in_hexa = "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3" | ||
|
||
message_broadcaster = MsgBroadcasterWithPk.new_without_simulation( | ||
network=network, | ||
private_key=private_key_in_hexa, | ||
) | ||
|
||
priv_key = PrivateKey.from_hex(private_key_in_hexa) | ||
pub_key = priv_key.to_public_key() | ||
address = pub_key.to_address() | ||
|
||
sender = address.to_acc_bech32() | ||
description = "Injective Test Token" | ||
subdenom = "inj_test" | ||
denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test" | ||
token_decimals = 6 | ||
name = "Injective Test" | ||
symbol = "INJTEST" | ||
uri = "http://injective-test.com/icon.jpg" | ||
uri_hash = "" | ||
|
||
message = composer.msg_set_denom_metadata( | ||
sender=sender, | ||
description=description, | ||
denom=denom, | ||
subdenom=subdenom, | ||
token_decimals=token_decimals, | ||
name=name, | ||
symbol=symbol, | ||
uri=uri, | ||
uri_hash=uri_hash, | ||
) | ||
|
||
# broadcast the transaction | ||
result = await message_broadcaster.broadcast([message]) | ||
print("---Transaction Response---") | ||
print(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import asyncio | ||
|
||
from pyinjective.composer import Composer as ProtoMsgComposer | ||
from pyinjective.core.broadcaster import MsgBroadcasterWithPk | ||
from pyinjective.core.network import Network | ||
from pyinjective.wallet import PrivateKey | ||
|
||
|
||
async def main() -> None: | ||
# select network: local, testnet, mainnet | ||
network = Network.testnet() | ||
composer = ProtoMsgComposer(network=network.string()) | ||
private_key_in_hexa = "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3" | ||
|
||
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation( | ||
network=network, | ||
private_key=private_key_in_hexa, | ||
) | ||
|
||
priv_key = PrivateKey.from_hex(private_key_in_hexa) | ||
pub_key = priv_key.to_public_key() | ||
address = pub_key.to_address() | ||
|
||
message = composer.msg_update_params( | ||
authority=address.to_acc_bech32(), | ||
denom="factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test", | ||
amount=1000, | ||
) | ||
|
||
# broadcast the transaction | ||
result = await message_broadcaster.broadcast([message]) | ||
print("---Transaction Response---") | ||
print(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import asyncio | ||
|
||
from pyinjective.composer import Composer as ProtoMsgComposer | ||
from pyinjective.core.broadcaster import MsgBroadcasterWithPk | ||
from pyinjective.core.network import Network | ||
from pyinjective.wallet import PrivateKey | ||
|
||
|
||
async def main() -> None: | ||
# select network: local, testnet, mainnet | ||
network = Network.testnet() | ||
composer = ProtoMsgComposer(network=network.string()) | ||
private_key_in_hexa = "f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3" | ||
|
||
message_broadcaster = MsgBroadcasterWithPk.new_without_simulation( | ||
network=network, | ||
private_key=private_key_in_hexa, | ||
) | ||
|
||
priv_key = PrivateKey.from_hex(private_key_in_hexa) | ||
pub_key = priv_key.to_public_key() | ||
address = pub_key.to_address() | ||
|
||
message = composer.msg_change_admin( | ||
sender=address.to_acc_bech32(), | ||
denom="factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test", | ||
new_admin="inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49", # This is the zero address to remove admin permissions | ||
) | ||
|
||
# broadcast the transaction | ||
result = await message_broadcaster.broadcast([message]) | ||
print("---Transaction Response---") | ||
print(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.