@@ -11,10 +11,12 @@ This module provides the foundation for typesafe Coins.
1111- [ Resource ` CoinStore ` ] ( #0x1_coin_CoinStore )
1212- [ Resource ` SupplyConfig ` ] ( #0x1_coin_SupplyConfig )
1313- [ Resource ` CoinInfo ` ] ( #0x1_coin_CoinInfo )
14- - [ Struct ` DepositEvent ` ] ( #0x1_coin_DepositEvent )
14+ - [ Struct ` CoinDeposit ` ] ( #0x1_coin_CoinDeposit )
15+ - [ Struct ` CoinWithdraw ` ] ( #0x1_coin_CoinWithdraw )
1516- [ Struct ` Deposit ` ] ( #0x1_coin_Deposit )
16- - [ Struct ` WithdrawEvent ` ] ( #0x1_coin_WithdrawEvent )
1717- [ Struct ` Withdraw ` ] ( #0x1_coin_Withdraw )
18+ - [ Struct ` DepositEvent ` ] ( #0x1_coin_DepositEvent )
19+ - [ Struct ` WithdrawEvent ` ] ( #0x1_coin_WithdrawEvent )
1820- [ Struct ` CoinEventHandleDeletion ` ] ( #0x1_coin_CoinEventHandleDeletion )
1921- [ Struct ` PairCreation ` ] ( #0x1_coin_PairCreation )
2022- [ Resource ` MigrationFlag ` ] ( #0x1_coin_MigrationFlag )
@@ -350,14 +352,15 @@ Information about a specific coin type. Stored on the creator of the coin's acco
350352
351353</details >
352354
353- <a id =" 0x1_coin_DepositEvent " ></a >
355+ <a id =" 0x1_coin_CoinDeposit " ></a >
354356
355- ## Struct ` DepositEvent `
357+ ## Struct ` CoinDeposit `
356358
357- Event emitted when some amount of a coin is deposited into an account.
359+ Module event emitted when some amount of a coin is deposited into an account.
358360
359361
360- <pre ><code ><b >struct</b > <a href =" coin.md#0x1_coin_DepositEvent " >DepositEvent</a > <b >has</b > drop, store
362+ <pre ><code >#[<a href =" event.md#0x1_event " >event</a >]
363+ <b >struct</b > <a href =" coin.md#0x1_coin_CoinDeposit " >CoinDeposit</a > <b >has</b > drop, store
361364</code ></pre >
362365
363366
@@ -368,6 +371,18 @@ Event emitted when some amount of a coin is deposited into an account.
368371
369372<dl >
370373<dt >
374+ <code >coin_type: <a href =" ../../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String " >string::String</a ></code >
375+ </dt >
376+ <dd >
377+
378+ </dd >
379+ <dt >
380+ <code ><a href =" account.md#0x1_account " >account</a >: <b >address</b ></code >
381+ </dt >
382+ <dd >
383+
384+ </dd >
385+ <dt >
371386<code >amount: u64</code >
372387</dt >
373388<dd >
@@ -378,15 +393,15 @@ Event emitted when some amount of a coin is deposited into an account.
378393
379394</details >
380395
381- <a id =" 0x1_coin_Deposit " ></a >
396+ <a id =" 0x1_coin_CoinWithdraw " ></a >
382397
383- ## Struct ` Deposit `
398+ ## Struct ` CoinWithdraw `
384399
385- Module event emitted when some amount of a coin is deposited into an account.
400+ Module event emitted when some amount of a coin is withdrawn from an account.
386401
387402
388403<pre ><code >#[<a href =" event.md#0x1_event " >event</a >]
389- <b >struct</b > <a href =" coin.md#0x1_coin_Deposit " >Deposit </a >& lt ; CoinType & gt ; <b >has</b > drop, store
404+ <b >struct</b > <a href =" coin.md#0x1_coin_CoinWithdraw " >CoinWithdraw </a > <b >has</b > drop, store
390405</code ></pre >
391406
392407
@@ -397,6 +412,12 @@ Module event emitted when some amount of a coin is deposited into an account.
397412
398413<dl >
399414<dt >
415+ <code >coin_type: <a href =" ../../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String " >string::String</a ></code >
416+ </dt >
417+ <dd >
418+
419+ </dd >
420+ <dt >
400421<code ><a href =" account.md#0x1_account " >account</a >: <b >address</b ></code >
401422</dt >
402423<dd >
@@ -413,14 +434,15 @@ Module event emitted when some amount of a coin is deposited into an account.
413434
414435</details >
415436
416- <a id =" 0x1_coin_WithdrawEvent " ></a >
437+ <a id =" 0x1_coin_Deposit " ></a >
417438
418- ## Struct ` WithdrawEvent `
439+ ## Struct ` Deposit `
419440
420- Event emitted when some amount of a coin is withdrawn from an account.
421441
422442
423- <pre ><code ><b >struct</b > <a href =" coin.md#0x1_coin_WithdrawEvent " >WithdrawEvent</a > <b >has</b > drop, store
443+ <pre ><code >#[<a href =" event.md#0x1_event " >event</a >]
444+ #[deprecated]
445+ <b >struct</b > <a href =" coin.md#0x1_coin_Deposit " >Deposit</a >< ; CoinType> ; <b >has</b > drop, store
424446</code ></pre >
425447
426448
@@ -431,6 +453,12 @@ Event emitted when some amount of a coin is withdrawn from an account.
431453
432454<dl >
433455<dt >
456+ <code ><a href =" account.md#0x1_account " >account</a >: <b >address</b ></code >
457+ </dt >
458+ <dd >
459+
460+ </dd >
461+ <dt >
434462<code >amount: u64</code >
435463</dt >
436464<dd >
@@ -445,10 +473,10 @@ Event emitted when some amount of a coin is withdrawn from an account.
445473
446474## Struct ` Withdraw `
447475
448- Module event emitted when some amount of a coin is withdrawn from an account.
449476
450477
451478<pre ><code >#[<a href =" event.md#0x1_event " >event</a >]
479+ #[deprecated]
452480<b >struct</b > <a href =" coin.md#0x1_coin_Withdraw " >Withdraw</a >< ; CoinType> ; <b >has</b > drop, store
453481</code ></pre >
454482
@@ -474,6 +502,62 @@ Module event emitted when some amount of a coin is withdrawn from an account.
474502</dl >
475503
476504
505+ </details >
506+
507+ <a id =" 0x1_coin_DepositEvent " ></a >
508+
509+ ## Struct ` DepositEvent `
510+
511+ Event emitted when some amount of a coin is deposited into an account.
512+
513+
514+ <pre ><code ><b >struct</b > <a href =" coin.md#0x1_coin_DepositEvent " >DepositEvent</a > <b >has</b > drop, store
515+ </code ></pre >
516+
517+
518+
519+ <details >
520+ <summary >Fields</summary >
521+
522+
523+ <dl >
524+ <dt >
525+ <code >amount: u64</code >
526+ </dt >
527+ <dd >
528+
529+ </dd >
530+ </dl >
531+
532+
533+ </details >
534+
535+ <a id =" 0x1_coin_WithdrawEvent " ></a >
536+
537+ ## Struct ` WithdrawEvent `
538+
539+ Event emitted when some amount of a coin is withdrawn from an account.
540+
541+
542+ <pre ><code ><b >struct</b > <a href =" coin.md#0x1_coin_WithdrawEvent " >WithdrawEvent</a > <b >has</b > drop, store
543+ </code ></pre >
544+
545+
546+
547+ <details >
548+ <summary >Fields</summary >
549+
550+
551+ <dl >
552+ <dt >
553+ <code >amount: u64</code >
554+ </dt >
555+ <dd >
556+
557+ </dd >
558+ </dl >
559+
560+
477561</details >
478562
479563<a id =" 0x1_coin_CoinEventHandleDeletion " ></a >
@@ -2728,7 +2812,9 @@ Deposit the coin balance into the recipient's account and emit an event.
27282812 <a href =" ../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_permission_denied " >error::permission_denied</a >(<a href =" coin.md#0x1_coin_EFROZEN " >EFROZEN</a >),
27292813 );
27302814 <b >if</b > (std::features::module_event_migration_enabled()) {
2731- <a href =" event.md#0x1_event_emit " >event::emit</a >(<a href =" coin.md#0x1_coin_Deposit " >Deposit</a >< ; CoinType> ; { <a href =" account.md#0x1_account " >account</a >: account_addr, amount: <a href =" coin.md#0x1_coin " >coin</a >.value });
2815+ <a href =" event.md#0x1_event_emit " >event::emit</a >(
2816+ <a href =" coin.md#0x1_coin_CoinDeposit " >CoinDeposit</a > { coin_type: type_name< ; CoinType> ; (), <a href =" account.md#0x1_account " >account</a >: account_addr, amount: <a href =" coin.md#0x1_coin " >coin</a >.value }
2817+ );
27322818 };
27332819 <a href =" event.md#0x1_event_emit_event " >event::emit_event</a >< ; <a href =" coin.md#0x1_coin_DepositEvent " >DepositEvent</a >> ; (
27342820 &<b >mut</b > coin_store.deposit_events,
@@ -3348,7 +3434,11 @@ Withdraw specified <code>amount</code> of coin <code>CoinType</code> from the si
33483434 <a href =" ../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_permission_denied " >error::permission_denied</a >(<a href =" coin.md#0x1_coin_EFROZEN " >EFROZEN</a >),
33493435 );
33503436 <b >if</b > (std::features::module_event_migration_enabled()) {
3351- <a href =" event.md#0x1_event_emit " >event::emit</a >(<a href =" coin.md#0x1_coin_Withdraw " >Withdraw</a >< ; CoinType> ; { <a href =" account.md#0x1_account " >account</a >: account_addr, amount: coin_amount_to_withdraw });
3437+ <a href =" event.md#0x1_event_emit " >event::emit</a >(
3438+ <a href =" coin.md#0x1_coin_CoinWithdraw " >CoinWithdraw</a > {
3439+ coin_type: type_name< ; CoinType> ; (), <a href =" account.md#0x1_account " >account</a >: account_addr, amount: coin_amount_to_withdraw
3440+ }
3441+ );
33523442 };
33533443 <a href =" event.md#0x1_event_emit_event " >event::emit_event</a >< ; <a href =" coin.md#0x1_coin_WithdrawEvent " >WithdrawEvent</a >> ; (
33543444 &<b >mut</b > coin_store.withdraw_events,
@@ -3724,6 +3814,64 @@ initialize, initialize_internal, initialize_with_parallelizable_supply;
37243814
37253815
37263816
3817+
3818+ <a id =" 0x1_coin_spec_is_account_registered " ></a >
3819+
3820+
3821+ <pre ><code ><b >fun</b > <a href =" coin.md#0x1_coin_spec_is_account_registered " >spec_is_account_registered</a >< ; CoinType> ; (account_addr: <b >address</b >): bool {
3822+ <b >let</b > paired_metadata_opt = <a href =" coin.md#0x1_coin_spec_paired_metadata " >spec_paired_metadata</a >< ; CoinType> ; ();
3823+ <b >exists</b >< ; <a href =" coin.md#0x1_coin_CoinStore " >CoinStore</a >< ; CoinType> ;> ; (account_addr) || (<a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_is_some " >option::spec_is_some</a >(
3824+ paired_metadata_opt
3825+ ) && <a href =" primary_fungible_store.md#0x1_primary_fungible_store_spec_primary_store_exists " >primary_fungible_store::spec_primary_store_exists</a >(account_addr, <a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_borrow " >option::spec_borrow</a >(paired_metadata_opt)))
3826+ }
3827+ </code ></pre >
3828+
3829+
3830+
3831+
3832+ <a id =" 0x1_coin_CoinSubAbortsIf " ></a >
3833+
3834+
3835+ <pre ><code ><b >schema</b > <a href =" coin.md#0x1_coin_CoinSubAbortsIf " >CoinSubAbortsIf</a >< ; CoinType> ; {
3836+ amount: u64;
3837+ <b >let</b > addr = <a href =" ../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of " >type_info::type_of</a >< ; CoinType> ; ().account_address;
3838+ <b >let</b > maybe_supply = <b >global</b >< ; <a href =" coin.md#0x1_coin_CoinInfo " >CoinInfo</a >< ; CoinType> ;> ; (addr).<a href =" coin.md#0x1_coin_supply " >supply</a >;
3839+ <b >include</b > (<a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_some " >option::is_some</a >(
3840+ maybe_supply
3841+ )) ==> ; <a href =" optional_aggregator.md#0x1_optional_aggregator_SubAbortsIf " >optional_aggregator::SubAbortsIf</a > { <a href =" optional_aggregator.md#0x1_optional_aggregator " >optional_aggregator</a >: <a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_borrow " >option::borrow</a >(maybe_supply), value: amount };
3842+ }
3843+ </code ></pre >
3844+
3845+
3846+
3847+
3848+ <a id =" 0x1_coin_CoinAddAbortsIf " ></a >
3849+
3850+
3851+ <pre ><code ><b >schema</b > <a href =" coin.md#0x1_coin_CoinAddAbortsIf " >CoinAddAbortsIf</a >< ; CoinType> ; {
3852+ amount: u64;
3853+ <b >let</b > addr = <a href =" ../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of " >type_info::type_of</a >< ; CoinType> ; ().account_address;
3854+ <b >let</b > maybe_supply = <b >global</b >< ; <a href =" coin.md#0x1_coin_CoinInfo " >CoinInfo</a >< ; CoinType> ;> ; (addr).<a href =" coin.md#0x1_coin_supply " >supply</a >;
3855+ <b >include</b > (<a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_some " >option::is_some</a >(
3856+ maybe_supply
3857+ )) ==> ; <a href =" optional_aggregator.md#0x1_optional_aggregator_AddAbortsIf " >optional_aggregator::AddAbortsIf</a > { <a href =" optional_aggregator.md#0x1_optional_aggregator " >optional_aggregator</a >: <a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_borrow " >option::borrow</a >(maybe_supply), value: amount };
3858+ }
3859+ </code ></pre >
3860+
3861+
3862+
3863+
3864+ <a id =" 0x1_coin_AbortsIfNotExistCoinInfo " ></a >
3865+
3866+
3867+ <pre ><code ><b >schema</b > <a href =" coin.md#0x1_coin_AbortsIfNotExistCoinInfo " >AbortsIfNotExistCoinInfo</a >< ; CoinType> ; {
3868+ <b >let</b > addr = <a href =" ../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of " >type_info::type_of</a >< ; CoinType> ; ().account_address;
3869+ <b >aborts_if</b > !<b >exists</b >< ; <a href =" coin.md#0x1_coin_CoinInfo " >CoinInfo</a >< ; CoinType> ;> ; (addr);
3870+ }
3871+ </code ></pre >
3872+
3873+
3874+
37273875<a id =" @Specification_1_AggregatableCoin " ></a >
37283876
37293877### Struct ` AggregatableCoin `
@@ -4067,64 +4215,6 @@ Get address by reflection.
40674215
40684216
40694217
4070-
4071- <a id =" 0x1_coin_spec_is_account_registered " ></a >
4072-
4073-
4074- <pre ><code ><b >fun</b > <a href =" coin.md#0x1_coin_spec_is_account_registered " >spec_is_account_registered</a >< ; CoinType> ; (account_addr: <b >address</b >): bool {
4075- <b >let</b > paired_metadata_opt = <a href =" coin.md#0x1_coin_spec_paired_metadata " >spec_paired_metadata</a >< ; CoinType> ; ();
4076- <b >exists</b >< ; <a href =" coin.md#0x1_coin_CoinStore " >CoinStore</a >< ; CoinType> ;> ; (account_addr) || (<a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_is_some " >option::spec_is_some</a >(
4077- paired_metadata_opt
4078- ) && <a href =" primary_fungible_store.md#0x1_primary_fungible_store_spec_primary_store_exists " >primary_fungible_store::spec_primary_store_exists</a >(account_addr, <a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_spec_borrow " >option::spec_borrow</a >(paired_metadata_opt)))
4079- }
4080- </code ></pre >
4081-
4082-
4083-
4084-
4085- <a id =" 0x1_coin_CoinSubAbortsIf " ></a >
4086-
4087-
4088- <pre ><code ><b >schema</b > <a href =" coin.md#0x1_coin_CoinSubAbortsIf " >CoinSubAbortsIf</a >< ; CoinType> ; {
4089- amount: u64;
4090- <b >let</b > addr = <a href =" ../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of " >type_info::type_of</a >< ; CoinType> ; ().account_address;
4091- <b >let</b > maybe_supply = <b >global</b >< ; <a href =" coin.md#0x1_coin_CoinInfo " >CoinInfo</a >< ; CoinType> ;> ; (addr).<a href =" coin.md#0x1_coin_supply " >supply</a >;
4092- <b >include</b > (<a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_some " >option::is_some</a >(
4093- maybe_supply
4094- )) ==> ; <a href =" optional_aggregator.md#0x1_optional_aggregator_SubAbortsIf " >optional_aggregator::SubAbortsIf</a > { <a href =" optional_aggregator.md#0x1_optional_aggregator " >optional_aggregator</a >: <a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_borrow " >option::borrow</a >(maybe_supply), value: amount };
4095- }
4096- </code ></pre >
4097-
4098-
4099-
4100-
4101- <a id =" 0x1_coin_CoinAddAbortsIf " ></a >
4102-
4103-
4104- <pre ><code ><b >schema</b > <a href =" coin.md#0x1_coin_CoinAddAbortsIf " >CoinAddAbortsIf</a >< ; CoinType> ; {
4105- amount: u64;
4106- <b >let</b > addr = <a href =" ../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of " >type_info::type_of</a >< ; CoinType> ; ().account_address;
4107- <b >let</b > maybe_supply = <b >global</b >< ; <a href =" coin.md#0x1_coin_CoinInfo " >CoinInfo</a >< ; CoinType> ;> ; (addr).<a href =" coin.md#0x1_coin_supply " >supply</a >;
4108- <b >include</b > (<a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_some " >option::is_some</a >(
4109- maybe_supply
4110- )) ==> ; <a href =" optional_aggregator.md#0x1_optional_aggregator_AddAbortsIf " >optional_aggregator::AddAbortsIf</a > { <a href =" optional_aggregator.md#0x1_optional_aggregator " >optional_aggregator</a >: <a href =" ../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_borrow " >option::borrow</a >(maybe_supply), value: amount };
4111- }
4112- </code ></pre >
4113-
4114-
4115-
4116-
4117- <a id =" 0x1_coin_AbortsIfNotExistCoinInfo " ></a >
4118-
4119-
4120- <pre ><code ><b >schema</b > <a href =" coin.md#0x1_coin_AbortsIfNotExistCoinInfo " >AbortsIfNotExistCoinInfo</a >< ; CoinType> ; {
4121- <b >let</b > addr = <a href =" ../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of " >type_info::type_of</a >< ; CoinType> ; ().account_address;
4122- <b >aborts_if</b > !<b >exists</b >< ; <a href =" coin.md#0x1_coin_CoinInfo " >CoinInfo</a >< ; CoinType> ;> ; (addr);
4123- }
4124- </code ></pre >
4125-
4126-
4127-
41284218<a id =" @Specification_1_name " ></a >
41294219
41304220### Function ` name `
@@ -4505,27 +4595,6 @@ The creator of <code>CoinType</code> must be <code>@aptos_framework</code>.
45054595</code ></pre >
45064596
45074597
4508- Make sure <code >name</code > and <code >symbol</code > are legal length.
4509- Only the creator of <code >CoinType</code > can initialize.
4510-
4511-
4512- <a id =" 0x1_coin_InitializeInternalSchema " ></a >
4513-
4514-
4515- <pre ><code ><b >schema</b > <a href =" coin.md#0x1_coin_InitializeInternalSchema " >InitializeInternalSchema</a >< ; CoinType> ; {
4516- <a href =" account.md#0x1_account " >account</a >: <a href =" ../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer " >signer</a >;
4517- name: <a href =" ../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector " >vector</a >< ; u8> ; ;
4518- symbol: <a href =" ../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector " >vector</a >< ; u8> ; ;
4519- <b >let</b > account_addr = <a href =" ../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of " >signer::address_of</a >(<a href =" account.md#0x1_account " >account</a >);
4520- <b >let</b > coin_address = <a href =" ../../aptos-stdlib/doc/type_info.md#0x1_type_info_type_of " >type_info::type_of</a >< ; CoinType> ; ().account_address;
4521- <b >aborts_if</b > coin_address != account_addr;
4522- <b >aborts_if</b > <b >exists</b >< ; <a href =" coin.md#0x1_coin_CoinInfo " >CoinInfo</a >< ; CoinType> ;> ; (account_addr);
4523- <b >aborts_if</b > len(name) > ; <a href =" coin.md#0x1_coin_MAX_COIN_NAME_LENGTH " >MAX_COIN_NAME_LENGTH</a >;
4524- <b >aborts_if</b > len(symbol) > ; <a href =" coin.md#0x1_coin_MAX_COIN_SYMBOL_LENGTH " >MAX_COIN_SYMBOL_LENGTH</a >;
4525- }
4526- </code ></pre >
4527-
4528-
45294598
45304599<a id =" @Specification_1_initialize_internal " ></a >
45314600
0 commit comments