Skip to content

Commit

Permalink
V6.1.0
Browse files Browse the repository at this point in the history
- Update dependencies.
- Added Support for aptos graphQL.
- Fix Sui multisig address validator
  • Loading branch information
mrtnetwork committed Feb 18, 2025
1 parent 5c729d6 commit eb0a29b
Show file tree
Hide file tree
Showing 114 changed files with 3,915 additions and 234 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 6.1.0

- Update dependencies.
- Added Support for aptos graphQL.
- Fix Sui multisig address validator

## 6.0.0

- Update dependencies.
Expand Down
12 changes: 10 additions & 2 deletions example/lib/example/aptos/api_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import 'package:on_chain/on_chain.dart';
import 'provider_example.dart';

final AptosProvider aptosProvider =
AptosProvider(AptosHttpService("https://api.testnet.aptoslabs.com/"));
AptosProvider(AptosHttpService("https://api.testnet.aptoslabs.com/v1/"));
final AptosProvider aptosGraphQl = AptosProvider(
AptosHttpService("https://api.testnet.aptoslabs.com/v1/graphql"));
Future<AptosApiAccountData> getAccountInfo(AptosAddress address) async {
final r =
await aptosProvider.request(AptosRequestGetAccount(address: address));
Expand All @@ -15,12 +17,18 @@ Future<BigInt> getAccountSequence(AptosAddress address) async {
return r.sequenceNumber;
}

Future<String> simulate(AptosSignedTransaction transaction) async {
Future<String> submitTransaction(AptosSignedTransaction transaction) async {
final r = await aptosProvider.request(AptosRequestSubmitTransaction(
signedTransactionData: transaction.toBcs()));
return r.hash;
}

Future<List<AptosApiUserTransaction>> simulateTransaction(
AptosSignedTransaction transaction) async {
return await aptosProvider.request(AptosRequestSimulateTransaction(
signedTransactionData: transaction.toBcs()));
}

Future<int> getChainId() async {
final r = await aptosProvider.request(AptosRequestGetLedgerInfo());
return r.chainId;
Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/aptos/batch_transfer_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void main() async {
authenticator: AptosTransactionAuthenticatorEd25519(
publicKey: authenticator.publicKey,
signature: authenticator.signature));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0x392868c085edc7ee6e260996e235190d320d38b28eaa8a28e23a52f1362d66d5?network=testnet
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void main() async {
final signedTx = AptosSignedTransaction(
rawTransaction: transaction,
authenticator: AptosTransactionAuthenticatorSignleSender(authenticator));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0x9fc9c8bc59b7897a549ac39562393924cf1da916c1f91ade52261c9239dcca3a/changes?network=testnet
}
2 changes: 1 addition & 1 deletion example/lib/example/aptos/mint_token_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void main() async {
authenticator: AptosTransactionAuthenticatorEd25519(
publicKey: authenticator.publicKey,
signature: authenticator.signature));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0xf2e42c3bdff11f28c0e21884c9378cb20ac947880ca447d073c27b8cbc6a5a1b?network=testnet
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void main() async {
secondarySignerAddressess: [recipient.publicKey.toAddress()]);
final signedTx = AptosSignedTransaction(
rawTransaction: transaction, authenticator: txauthenticator);
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0xd23a797626830900976b198fcbce513ddd439ac9b3e8240630fdaee3a0feb42b?network=testnet
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void main() async {
authenticator: AptosTransactionAuthenticatorEd25519(
publicKey: authenticator.publicKey,
signature: authenticator.signature));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0x249366b3feadeac76979d083cdf35997cb9dff0d26b93fed3edf2cf402ddfb7e?network=testnet
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void main() async {
authenticator: AptosTransactionAuthenticatorEd25519(
publicKey: authenticator.publicKey,
signature: authenticator.signature));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0xeeb34e1318db474aeff5a9d43d53a0203936346cb63e4731c9d75e18798d0501?network=testnet
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ void main() async {
authenticator: AptosTransactionAuthenticatorEd25519(
publicKey: authenticator.publicKey,
signature: authenticator.signature));
await simulate(signedTx);
await submitTransaction(signedTx);
}
2 changes: 1 addition & 1 deletion example/lib/example/aptos/transfer_ft_assets_emxaple.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void main() async {
authenticator: AptosTransactionAuthenticatorEd25519(
publicKey: authenticator.publicKey,
signature: authenticator.signature));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0xafb3c380d3d53e9fe29ecc3e780beb2b07b0f04713efed4b0cda16f2bf423736?network=testnet
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void main() async {
final signedTx = AptosSignedTransaction(
rawTransaction: transaction,
authenticator: AptosTransactionAuthenticatorSignleSender(authenticator));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0xca98b094a215b68c1d1ef8f6a27111b9a6975b9ea7634a8323c3b40676855907?network=testnet
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void main() async {
sender: authenticator,
feePayerAuthenticator: payerAuthenticator,
feePayerAddress: payerAccount.toAddress()));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0x496884cf2aa8d2b47b17351a695edc996884dee7398f97e60e4bfa18d2575c21?network=testnet
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void main() async {
final signedTx = AptosSignedTransaction(
rawTransaction: transaction,
authenticator: AptosTransactionAuthenticatorSignleSender(authenticator));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0xec94e9f968a5534826626de0a3c7037e19d161dd9fec729ca580c854b9433dd9?network=testnet
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void main() async {
final signedTx = AptosSignedTransaction(
rawTransaction: transaction,
authenticator: AptosTransactionAuthenticatorSignleSender(authenticator));
await simulate(signedTx);
await submitTransaction(signedTx);

/// https://explorer.aptoslabs.com/txn/0x315cde98b8a76bda21010f2049bbb5c1002ed7e10d54c97e1b663d810a52cbb0?network=testnet
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void main() async {
final authenticator = AptosTransactionAuthenticatorSignleSender(signature);
final signedTransaction = AptosSignedTransaction(
rawTransaction: rawTransaction, authenticator: authenticator);
await simulate(signedTransaction);
await submitTransaction(signedTransaction);

/// https://explorer.aptoslabs.com/txn/0xec00544f9957f3130f0142a28707d6a2c1c9bd0717e1a8c18195efdd39463e02?network=testnet
}
35 changes: 20 additions & 15 deletions example/lib/example/sui/api_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,27 @@ Future<List<SuiApiCoinResponse>> getCoins(SuiAddress address) async {
Future<SuiTransactionDataV1> filledGasPayment(SuiTransactionDataV1 tx) async {
final coins = await getCoins(tx.gasData.owner);
final kind = tx.kind.cast<SuiTransactionKindProgrammableTransaction>();
final objectsInput = kind.transaction.inputs.whereType<SuiCallArgObject>();
final filterCoins = coins
.where((e) {
for (final i in objectsInput) {
if (i.object.type == SuiObjectArgs.immOrOwnedObject) {
final imm = i.object.cast<SuiObjectArgImmOrOwnedObject>();
if (imm.immOrOwnedObject.address == e.coinObjectId) return false;
}
return true;
}
return true;
})
.map((e) => e.toObjectRef())
final ownedObjectAddresses = kind.transaction.inputs
.whereType<SuiCallArgObject>()
.map((e) => e.object)
.whereType<SuiObjectArgImmOrOwnedObject>()
.map((e) => e.immOrOwnedObject.address);

List<SuiApiCoinResponse> filterCoins = coins
.where((e) => !ownedObjectAddresses.contains(e.coinObjectId))
.toList();
assert(filterCoins.isNotEmpty);
return tx.copyWith(gasData: tx.gasData.copyWith(payment: filterCoins));
assert(filterCoins.isNotEmpty, "leak of gas token");
List<SuiObjectRef> gasTokens = [];
final BigInt gasBudget = tx.gasData.budget;
BigInt sum = BigInt.zero;
for (final i in filterCoins) {
gasTokens.add(i.toObjectRef());
sum += i.balance;
if (sum >= gasBudget) break;
}
assert(sum >= gasBudget,
"Insufficient balance: required ${SuiHelper.toSui(gasBudget)} available: ${SuiHelper.toSui(sum)}");
return tx.copyWith(gasData: tx.gasData.copyWith(payment: gasTokens));
}

Future<SuiApiTransactionBlockResponse> excuteTx(
Expand Down
Loading

0 comments on commit eb0a29b

Please sign in to comment.