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

Extend solana plugin #648

Merged
merged 10 commits into from
Nov 15, 2023
4 changes: 2 additions & 2 deletions docs/api/plugins/aea_ledger_solana/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ True if the `pubkey` can be loaded as a read-write account.

```python
@classmethod
def from_solders(cls, meta: instruction.AccountMeta)
def from_solders(cls, meta: AccountMeta)
```

Convert from a `solders` AccountMeta.
Expand All @@ -49,7 +49,7 @@ Convert from a `solders` AccountMeta.
#### to`_`solders

```python
def to_solders() -> instruction.AccountMeta
def to_solders() -> AccountMeta
```

Convert to a `solders` AccountMeta.
Expand Down
11 changes: 11 additions & 0 deletions docs/api/plugins/aea_ledger_solana/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ Instantiate a solana crypto object.
- `password`: the password to encrypt/decrypt the private key.
- `extra_entropy`: add extra randomness to whatever randomness from OS.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.crypto.SolanaCrypto.pubkey"></a>

#### pubkey

```python
@property
def pubkey() -> Pubkey
```

Pubkey object.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.crypto.SolanaCrypto.private_key"></a>

#### private`_`key
Expand Down
202 changes: 165 additions & 37 deletions docs/api/plugins/aea_ledger_solana/solana.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ Initialize the Solana ledger APIs.

- `kwargs`: keyword arguments

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.api"></a>

#### api

```python
@property
def api() -> SolanaApiClient
```

Get the underlying API object.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.latest_hash"></a>

#### latest`_`hash
Expand All @@ -39,6 +50,99 @@ def latest_hash()

Get the latest hash.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.system_program"></a>

#### system`_`program

```python
@property
def system_program() -> Pubkey
```

System program.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.sol_to_lamp"></a>

#### sol`_`to`_`lamp

```python
@staticmethod
def sol_to_lamp(sol: float) -> int
```

Solana to lamport value.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.to_account_meta"></a>

#### to`_`account`_`meta

```python
@classmethod
def to_account_meta(cls, pubkey: Union[Pubkey, str], is_signer: bool,
is_writable: bool) -> AccountMeta
```

To account meta.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.to_pubkey"></a>

#### to`_`pubkey

```python
@staticmethod
def to_pubkey(key: Union[SolanaCrypto, Keypair, Pubkey, str]) -> Pubkey
```

To pubkey.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.to_keypair"></a>

#### to`_`keypair

```python
@staticmethod
def to_keypair(key: Union[SolanaCrypto, Keypair, str]) -> Pubkey
```

To keypair object.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.pda"></a>

#### pda

```python
@staticmethod
def pda(seeds: Sequence[bytes], program_id: Pubkey) -> Pubkey
```

Create TX PDA

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.create_pda"></a>

#### create`_`pda

```python
@staticmethod
def create_pda(from_address: str, new_account_address: str, base_address: str,
seed: str, lamports: int, space: int, program_id: str)
```

Build a create pda transaction.

**Arguments**:

- `from_address`: the sender public key
- `new_account_address`: the new account public key
- `base_address`: base address
- `seed`: seed
- `lamports`: the amount of lamports to send
- `space`: the space to allocate
- `program_id`: the program id

**Returns**:

the tx, if present

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.wait_get_receipt"></a>

#### wait`_`get`_`receipt
Expand All @@ -61,17 +165,6 @@ def construct_and_settle_tx(account1: SolanaCrypto, account2: SolanaCrypto,

Construct and settle a transaction.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.api"></a>

#### api

```python
@property
def api() -> SolanaApiClient
```

Get the underlying API object.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.update_with_gas_estimate"></a>

#### update`_`with`_`gas`_`estimate
Expand Down Expand Up @@ -259,32 +352,6 @@ Build a create account transaction.

the tx, if present

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.create_pda"></a>

#### create`_`pda

```python
@staticmethod
def create_pda(from_address: str, new_account_address: str, base_address: str,
seed: str, lamports: int, space: int, program_id: str)
```

Build a create pda transaction.

**Arguments**:

- `from_address`: the sender public key
- `new_account_address`: the new account public key
- `base_address`: base address
- `seed`: seed
- `lamports`: the amount of lamports to send
- `space`: the space to allocate
- `program_id`: the program id

**Returns**:

the tx, if present

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.get_contract_instance"></a>

#### get`_`contract`_`instance
Expand Down Expand Up @@ -379,6 +446,67 @@ Prepare a transaction

the transaction

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.build_instruction"></a>

#### build`_`instruction

```python
def build_instruction(
contract_instance: Program,
method_name: str,
data: List[Any],
accounts: Dict[str, Pubkey],
remaining_accounts: Optional[List[AccountMeta]] = None) -> JSONLike
```

Prepare an instruction

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.serialize_tx"></a>

#### serialize`_`tx

```python
def serialize_tx(
tx: Union[Dict, SolanaTransaction, SoldersTransaction,
SoldersVersionedTransaction]
) -> Dict
```

Serialize transaction to solders transaction compatible json object.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.deserialize_tx"></a>

#### deserialize`_`tx

```python
def deserialize_tx(
tx: Union[Dict, SolanaTransaction, SoldersTransaction,
SoldersVersionedTransaction]
) -> SolanaTransaction
```

Deserialize transaction to a solana transaction object.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.serialize_ix"></a>

#### serialize`_`ix

```python
def serialize_ix(ix: Instruction) -> Dict
```

Serialize instruction.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.deserialize_ix"></a>

#### deserialize`_`ix

```python
def deserialize_ix(ix: Dict) -> Instruction
```

Deserialize instruction.

<a id="plugins.aea-ledger-solana.aea_ledger_solana.solana.SolanaApi.get_transaction_transfer_logs"></a>

#### get`_`transaction`_`transfer`_`logs
Expand Down
2 changes: 1 addition & 1 deletion packages/fetchai/skills/erc1155_client/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fingerprint:
tests/test_strategy.py: bafybeicbxie3v6vue3gcnru6vsvggcgy3shxwrldis5gppizbuhooslcqa
fingerprint_ignore_patterns: []
connections:
- valory/ledger:0.19.0:bafybeigdckv3e6bz6kfloz4ucqrsufft6k4jp6bwkbbcvh4fxvgbmzq3dm
- valory/ledger:0.19.0:bafybeia47rr37ianvwsh77tjjpv3nwif5sywhhy2fbdshnz4a2icwln76a
contracts:
- fetchai/erc1155:0.22.0:bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4
protocols:
Expand Down
2 changes: 1 addition & 1 deletion packages/fetchai/skills/erc1155_deploy/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fingerprint:
tests/test_strategy.py: bafybeigxtw2j2c7vl6xhdwos62jbtmx62xfgdyadptm5eewmkesmcooyea
fingerprint_ignore_patterns: []
connections:
- valory/ledger:0.19.0:bafybeigdckv3e6bz6kfloz4ucqrsufft6k4jp6bwkbbcvh4fxvgbmzq3dm
- valory/ledger:0.19.0:bafybeia47rr37ianvwsh77tjjpv3nwif5sywhhy2fbdshnz4a2icwln76a
contracts:
- fetchai/erc1155:0.22.0:bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4
protocols:
Expand Down
2 changes: 1 addition & 1 deletion packages/fetchai/skills/generic_buyer/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fingerprint:
tests/test_models.py: bafybeibh72j3n72yseqvmpppucpu5wtidf6ebxbxkfnmrnlh4zv5y5apei
fingerprint_ignore_patterns: []
connections:
- valory/ledger:0.19.0:bafybeigdckv3e6bz6kfloz4ucqrsufft6k4jp6bwkbbcvh4fxvgbmzq3dm
- valory/ledger:0.19.0:bafybeia47rr37ianvwsh77tjjpv3nwif5sywhhy2fbdshnz4a2icwln76a
contracts: []
protocols:
- fetchai/default:1.0.0:bafybeibtqp56jkijwjsohk4z5vqp6pfkiexmnmk5uleteotbsgrypy6gxm
Expand Down
2 changes: 1 addition & 1 deletion packages/fetchai/skills/generic_seller/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fingerprint:
tests/test_models.py: bafybeihabrc22zqssit3fmqhxptosy6qz6mx65ukhf5iayvirfv42xrhoq
fingerprint_ignore_patterns: []
connections:
- valory/ledger:0.19.0:bafybeigdckv3e6bz6kfloz4ucqrsufft6k4jp6bwkbbcvh4fxvgbmzq3dm
- valory/ledger:0.19.0:bafybeia47rr37ianvwsh77tjjpv3nwif5sywhhy2fbdshnz4a2icwln76a
contracts: []
protocols:
- fetchai/default:1.0.0:bafybeibtqp56jkijwjsohk4z5vqp6pfkiexmnmk5uleteotbsgrypy6gxm
Expand Down
10 changes: 5 additions & 5 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"protocol/valory/http/1.0.0": "bafybeiejoqgv7finfxo3rcvvovrlj5ccrbgxodjq43uo26ylpowsa3llfe",
"protocol/valory/ledger_api/1.0.0": "bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru",
"connection/fetchai/stub/0.21.0": "bafybeictgpdqbpyppmoxn2g7jkaxvulihew7zaszv4xyhgvsntq7tqs7wi",
"connection/valory/ledger/0.19.0": "bafybeigdckv3e6bz6kfloz4ucqrsufft6k4jp6bwkbbcvh4fxvgbmzq3dm",
"connection/valory/ledger/0.19.0": "bafybeia47rr37ianvwsh77tjjpv3nwif5sywhhy2fbdshnz4a2icwln76a",
"connection/valory/http_server/0.22.0": "bafybeid4nl6ruidpto3ynwjmc76nf42egcroqlhqq6krh2onwktu4ywpne",
"connection/valory/p2p_libp2p/0.1.0": "bafybeiaykya7tvir7k5scovjzuagpfcftvptxoi2od5qqqvukwglsrrtzy",
"connection/valory/p2p_libp2p_client/0.1.0": "bafybeihge56dn3xep2dzomu7rtvbgo4uc2qqh7ljl3fubqdi2lq44gs5lq",
Expand All @@ -32,12 +32,12 @@
"connection/valory/http_client/0.23.0": "bafybeiddrfvomrmgvh5yuv2coq7ci72wcdf663stayi3m5aawnj4srggce",
"connection/valory/test_libp2p/0.1.0": "bafybeidy7qyswtj2fnh2q3qnusevamllw2ozzu723sh52r4k4gna3ig4e4",
"protocol/fetchai/tac/1.0.0": "bafybeiaukfwe7wbpikztprlmrfpphsxqpdzgamkbhvqyz54tl3k73kzsvi",
"skill/fetchai/erc1155_client/0.28.0": "bafybeid3npgiuvgjyocxtxl6ovihrnicd5ezlim4aq4ytl3atnm5yywxmu",
"skill/fetchai/erc1155_deploy/0.30.0": "bafybeie2lqwsqgpv35uy7nztohtukvogntsxqi74x37qsbsx7drgeajtau",
"skill/fetchai/erc1155_client/0.28.0": "bafybeiclxy64l364o7ek3imuwl4fnmtagy3j2coy6l7ga3gyt2lqzqifkq",
"skill/fetchai/erc1155_deploy/0.30.0": "bafybeiftychtjk7pz2ircduucnfpqpxduhk5ddvouzhkaq2vnfssozbgpa",
"skill/fetchai/error/0.17.0": "bafybeignei6feootyjzrqdt5j5yx7r4nrzuy6tdgdgsmrncldt5bud2dri",
"skill/fetchai/fipa_dummy_buyer/0.2.0": "bafybeid7rzqruvc3fkesueig2mbzy2qsfplieircyjzwbdl7c6q5eauiky",
"skill/fetchai/generic_buyer/0.26.0": "bafybeibiplanh6h2biy27wt26jnzwftfsji77ajp26hcule5q2acjq3fjy",
"skill/fetchai/generic_seller/0.27.0": "bafybeiboyk6q2sl6rdqvcksbg4gnfb766vpexrdcgjmxzm3kjmcsjnsvia",
"skill/fetchai/generic_buyer/0.26.0": "bafybeifyesl5ooduzfmjw4br2avinyxjbndiwsagwsjtxgrxtzchjyhcxy",
"skill/fetchai/generic_seller/0.27.0": "bafybeiablwq6oefmojsgj3yvedvo5b2bu4yosdr7k5cwn4xkcs4hxeb6fm",
"skill/fetchai/task_test_skill/0.1.0": "bafybeidv77u2xl52mnxakwvh7fuh46aiwfpteyof4eaptfd4agoi6cdble"
},
"third_party": {}
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/connections/ledger/connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fingerprint:
tests/conftest.py: bafybeid7vo7e2m76ey5beeadtbxywxx5ukefd5slwbc362rwmhht6i45ou
tests/test_contract_dispatcher.py: bafybeiag5lnpc7h25w23ash4hk4cowxsy5buxgpr474l3tfewnhf56eqyq
tests/test_ledger.py: bafybeigcedfr3yv3jse3xwrerrgwbelgb56uhgrvdus527d3daekh6dx4m
tests/test_ledger_api.py: bafybeifwdpbds7ujd2uzxcapprdgdp5fn2gpbycsgbbefbsabrucnvrfiq
tests/test_ledger_api.py: bafybeifw5smawex5m2fm6rt4kmunc22kpabalmshh45qb3xnuap33sfgyi
fingerprint_ignore_patterns: []
connections: []
protocols:
Expand Down
3 changes: 2 additions & 1 deletion packages/valory/connections/ledger/tests/test_ledger_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@
(EthereumCrypto.identifier, EthereumCrypto(ETHEREUM_PRIVATE_KEY_PATH).address),
],
)
# TODO: uncomment gas station strategy config after the gasstation API start
gas_strategies = pytest.mark.parametrize(
"gas_strategies",
[
{"gas_price_strategy": None},
{"gas_price_strategy": "gas_station"},
# {"gas_price_strategy": "gas_station"}, # noqa:E800
{"gas_price_strategy": "eip1559"},
{
"max_fee_per_gas": 1_000_000_000,
Expand Down
8 changes: 4 additions & 4 deletions plugins/aea-ledger-solana/aea_ledger_solana/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""Solana account implementation."""
from dataclasses import dataclass

from solders import instruction
from solders.instruction import AccountMeta
from solders.pubkey import Pubkey as PublicKey


Expand All @@ -35,16 +35,16 @@ class AccountMeta:
"""True if the `pubkey` can be loaded as a read-write account."""

@classmethod
def from_solders(cls, meta: instruction.AccountMeta):
def from_solders(cls, meta: AccountMeta):
"""Convert from a `solders` AccountMeta."""
return cls(
pubkey=PublicKey.from_bytes(bytes(meta.pubkey)),
is_signer=meta.is_signer,
is_writable=meta.is_writable,
)

def to_solders(self) -> instruction.AccountMeta:
def to_solders(self) -> AccountMeta:
"""Convert to a `solders` AccountMeta."""
return instruction.AccountMeta(
return AccountMeta(
pubkey=self.pubkey, is_signer=self.is_signer, is_writable=self.is_writable
)
Loading
Loading