Skip to content

[pull] master from broxus:master #19

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

Merged
merged 1 commit into from
May 20, 2025
Merged
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nekoton-python"
version = "0.1.22"
version = "0.1.23"
edition = "2021"

[lib]
125 changes: 108 additions & 17 deletions python/nekoton/contracts/ever_wallet.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,93 @@
from typing import Optional
from typing import Optional, List

from . import IGiver
import nekoton as _nt


_wallet_abi = _nt.ContractAbi("""{
"ABI version": 2,
"version": "2.3",
"header": ["pubkey", "time", "expire"],
"functions": [{
"name": "sendTransaction",
"inputs": [
{"name": "dest", "type": "address"},
{"name": "value", "type": "uint128"},
{"name": "bounce", "type": "bool"},
{"name": "flags", "type": "uint8"},
{"name": "payload", "type": "cell"}
],
"outputs": []
}],
"events": []
}""")
"ABI version": 2,
"version": "2.3",
"header": ["pubkey", "time", "expire"],
"functions": [
{
"name": "sendTransaction",
"inputs": [
{ "name": "dest", "type": "address" },
{ "name": "value", "type": "uint128" },
{ "name": "bounce", "type": "bool" },
{ "name": "flags", "type": "uint8" },
{ "name": "payload", "type": "cell" }
],
"outputs": []
},
{
"name": "sendTransactionRaw0",
"inputs": [],
"outputs": [],
"id": "0x169e3e11"
},
{
"name": "sendTransactionRaw1",
"inputs": [
{ "name": "flags0", "type": "uint8" },
{ "name": "message0", "type": "cell" }
],
"outputs": [],
"id": "0x169e3e11"
},
{
"name": "sendTransactionRaw2",
"inputs": [
{ "name": "flags0", "type": "uint8" },
{ "name": "message0", "type": "cell" },
{ "name": "flags1", "type": "uint8" },
{ "name": "message1", "type": "cell" }
],
"outputs": [],
"id": "0x169e3e11"
},
{
"name": "sendTransactionRaw3",
"inputs": [
{ "name": "flags0", "type": "uint8" },
{ "name": "message0", "type": "cell" },
{ "name": "flags1", "type": "uint8" },
{ "name": "message1", "type": "cell" },
{ "name": "flags2", "type": "uint8" },
{ "name": "message2", "type": "cell" }
],
"outputs": [],
"id": "0x169e3e11"
},
{
"name": "sendTransactionRaw4",
"inputs": [
{ "name": "flags0", "type": "uint8" },
{ "name": "message0", "type": "cell" },
{ "name": "flags1", "type": "uint8" },
{ "name": "message1", "type": "cell" },
{ "name": "flags2", "type": "uint8" },
{ "name": "message2", "type": "cell" },
{ "name": "flags3", "type": "uint8" },
{ "name": "message3", "type": "cell" }
],
"outputs": [],
"id": "0x169e3e11"
}
],
"events": []
}
""")

_send_transaction = _wallet_abi.get_function("sendTransaction")
assert _send_transaction is not None

_send_transaction_raw = list()
for i in range(4):
abi = _wallet_abi.get_function(f"sendTransactionRaw{i}")
assert abi is not None
_send_transaction_raw.append(abi)

_wallet_code = _nt.Cell.decode(
"te6cckEBBgEA/AABFP8A9KQT9LzyyAsBAgEgAgMABNIwAubycdcBAcAA8nqDCNcY7UTQgwfXAdcLP8j4KM8WI88WyfkAA3HXAQHDAJqDB9cBURO68uBk3oBA1wGAINcBgCDXAVQWdfkQ8qj4I7vyeWa++COBBwiggQPoqFIgvLHydAIgghBM7mRsuuMPAcjL/8s/ye1UBAUAmDAC10zQ+kCDBtcBcdcBeNcB10z4AHCAEASqAhSxyMsFUAXPFlAD+gLLaSLQIc8xIddJoIQJuZgzcAHLAFjPFpcwcQHLABLM4skB+wAAPoIQFp4+EbqOEfgAApMg10qXeNcB1AL7AOjRkzLyPOI+zYS/"
)
@@ -104,6 +167,34 @@ async def send(
raise RuntimeError("Message expired")
return tx

async def send_raw(
self,
messages: List[tuple[_nt.Message, int]],
) -> _nt.Transaction:
if len(messages) > 4:
raise RuntimeError("Too many messages at once")

state_init = await self.__get_state_init()
signature_id = await self._transport.get_signature_id()

abi = _send_transaction_raw[len(messages)]
input = dict()
for i, (message, flags) in enumerate(messages):
input[f"flags{i}"] = flags
input[f"message{i}"] = message.build_cell()

external_message = abi.encode_external_message(
self._address,
input,
public_key=self._keypair.public_key,
state_init=state_init,
).sign(self._keypair, signature_id)

tx = await self._transport.send_external_message(external_message)
if tx is None:
raise RuntimeError("Message expired")
return tx

async def get_account_state(self) -> Optional[_nt.AccountState]:
return await self._transport.get_account_state(self._address)


Unchanged files with check annotations Beta

const result = fn(...args);
if (result && typeof result.then === 'function' && typeof result.catch === 'function') {
return result.catch((error: Error) => {
console.error(`Error: `, error);

Check warning on line 38 in docs/src/helpers/toast.ts

GitHub Actions / Generate docs

Unexpected console statement
toast(error.message, ToastType.ERROR);
throw error;
});
return result;
} catch (error: any) {
console.error(`Error: `, error);

Check warning on line 46 in docs/src/helpers/toast.ts

GitHub Actions / Generate docs

Unexpected console statement
if (error.message) {
toast(error.message, ToastType.ERROR);
} else {