Skip to content

Commit

Permalink
fix output_smc
Browse files Browse the repository at this point in the history
  • Loading branch information
sonson0910 committed Jan 10, 2024
1 parent b12f173 commit 5b5d8d0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 0 additions & 1 deletion CollectNFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ async function unlock(utxos, UTOut, { from, using }): Promise<TxHash> {
const payment_bider = { type: "Key", hash: UTOut.bider }
const payment_author = { type: "Key", hash: UTOut.author }


console.log(price);
// Initiate transaction
const tx = await lucid
Expand Down
16 changes: 16 additions & 0 deletions lib/alphabid/utils.ak
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ pub fn check_amount(output: Output, price: Int) -> Bool {
lovelace_of(output.value) >= price
}

pub fn check_amount_smc(output: Output, price: Int) -> Bool {
// With the amount in the output being greater than the amount passed in from the parameter
lovelace_of(output.value) > price
}

// Function to check address
pub fn check_address(output: Output, address: Address) -> Bool {
// Check the two payment addresses from the address in the output and the address passed in from the parameter
Expand Down Expand Up @@ -49,6 +54,17 @@ pub fn find_output(
)
}

pub fn find_output_smc(
outputs: List<Output>,
price: Int,
address: Address,
) -> Option<Output> {
list.find(
outputs,
fn(output) { check_amount(output, price) && check_address(output, address) },
)
}

pub fn find_output_Winter(
outputs: List<Output>,
policyId: PolicyId,
Expand Down
4 changes: 2 additions & 2 deletions plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"$ref": "#/definitions/Void"
}
},
"compiledCode": "5905ac01000032323232323232323222232533300732323232323232323232323253330133370e90010008a9998098010a511323232323232323232323232533301f33301f3322323253330233370e9001000899b89003375a605060420042940c084004c01cc07cc01cc07c008c030c07405cdd6981218129812980e80e2504a22646464a66604466e1d20000011323253330245333024337126eb4c044c088084c02cdd598061811000899b8733300d3756601860440026eb8c028c088084dd718061811010a400429404ccc090cdd7802260103d87a80004a0944528181400098100018a503020002333002012375a601a603c03a60146eb8c02cc078074ccc004044dd69806180e80e18049bae302430253025302530253025301d01c13232323232325333025001153330253371e6eb8c014c08c088dd7180b1811811099191919299981499b8948010c00400c4cdc4a400460026600800646601c0026eb4c05cc0a009c52818008009129998160008a4000266e01200233002002302f00133001018253330273300a0013011375c6030604a0482660160026eb4c05cc0940905281119198008008019129998160008a5eb804c8c94ccc0acc0140084cc0bc008cc0100100044cc010010004c0c0008c0b80045288a505333024533302453330243330243375e00698103d87a80004a09444ccc090cdd7801260103d87a80004a0944528099981219baf0054c0103d87a80004a0944528099981219baf0014c0103d87a80004a09445281999111980580c1299981399b873330103756601e604a00200800690010998050008010a50375c601260420406eb8c02cc084080c034dd71807181081019980200a00726150d8799fd8799f581c3a4e6757f24d9dddb65c8aef60d0999957b3650453e5e7721fb4fd42ffd8799fd8799fd8799f581c32798960f1b4dc35be90add0d31aed0e3019ea0e47288296a5737e60ffffffff00333003013375a6022603e03c60166eb8c004c07c0788c098c09cc09cc09cc09cc09cc09c004ccc004044dd69806180e80e18049bae3010301d01c22233006003253330223300600100313300500100214a04466ebcc014c074c014c074008c014c07400488cdc480098029bab3006301c00222323300100100322533302200114c0103d87a8000132325333021300500213374a90001981280125eb804cc010010004c098008c0900048c0800048ccc00c005221004881002301e301f001222323232533301d3370e90010008a400026eb4c088c06c008c06c004c94ccc070cdc3a4004002298103d87a8000132323300100100222533302200114c103d87a800013232323253330233371e014004266e95200033027375000297ae0133006006003375a60480066eb8c088008c098008c090004dd59810980d001180d000991980080080211299980f8008a6103d87a800013232323253330203371e010004266e95200033024374c00297ae0133006006003375660420066eb8c07c008c08c008c0840048cdd2a40006603666e9520003301b375200297ae03301b4c0103d87a80004bd701180d980e180e180e180e00099b833370490011bad3001301201148320048c064c068c068c068c068c068c068c06800452818088041919191980080080111299980c0008a501323253330173371e00400c29444cc010010004c070008dd7180d0009bac3002301000a375c6004601e01c4602c602e602e602e602e602e602e602e602e0024602a602c602c602c0026eb0c04c004c04c004c048004c02400cc03c004c03c008c034004c014008526136563253330073370e90000008991919191919191919191919191919191919299980e180f8010a4c2c6eb4c074004c074008dd6980d800980d8011bae30190013019002375c602e002602e0046eb8c054004c054008dd7180980098098011bad30110013011002375c601e002601e0046eb8c034004c01401058c01400c8c014dd5000918019baa0015734aae7555cf2ab9f5740ae855d11",
"hash": "f1f5543b03f8cdaac8689578569b597d88885b9fc480df7956925d24"
"compiledCode": "5905bf01000032323232323232323222232533300732323232323232323232323253330133370e90010008a9998098010a511323232323232323232323232533301f33301f3322323253330233370e9001000899b89003375a605060420042940c084004c020c07cc020c07c008c030c07405cdd6981218129812980e80e2504a22646464a66604466e1d20000011323253330245333024337126eb4c044c088084c030dd598069811000899b8733300e3756601a60440026eb8c02cc088084dd718069811010a400429404ccc090cdd7802260103d87a80004a0944528181400098100018a503020002333003012375a601a603c03a60046eb8c02cc078074cc88cc01c04c94ccc088cc01c00400c4cc0180040085281bad300c301d01c3001375c6048604a604a604a604a604a603a0382646464646464a66604a0022a66604a66e3cdd7180298118111bae3016302302213232323253330293371290021800801899b8948008c004cc01000c8cc03c004dd6980b98140138a50300100122533302c0011480004cdc02400466004004605e002660020304a66604e6601600260126eb8c060c0940904cc030004dd6980b98128120a5022323300100100322533302c00114bd70099192999815980280109981780119802002000899802002000981800118170008a5114a0a666048a666048a66604866604866ebc00d30103d87a80004a09444ccc090cdd7801260103d87a80004a0944528099981219baf0054c0103d87a80004a0944528099981219baf0014c0103d87a80004a09445281999111980600c1299981399b8733301137566020604a00200800690010998058008010a50375c601460420406eb8c030c084080c014dd71807181081019980280a00726150d8799fd8799f581c3a4e6757f24d9dddb65c8aef60d0999957b3650453e5e7721fb4fd42ffd8799fd8799fd8799f581c32798960f1b4dc35be90add0d31aed0e3019ea0e47288296a5737e60ffffffff00333004013375a6022603e03c60066eb8c004c07c0788c098c09cc09cc09cc09cc09cc09c004ccc008044dd69806180e80e18009bae3010301d01c23374a90001981199ba548000cc08cdd4800a5eb80cc08d300103d87a80004bd701111980300192999810998030008018998028008010a50223375e600a6038600a6038004600a60380024466e24004c014dd59803180d8011119198008008019129998108008a60103d87a8000132325333020300500213374a90001981200125eb804cc010010004c094008c08c0048c07c0048ccc00c005221004881002301d301e001222323232533301c3370e90010008a400026eb4c084c068008c068004c94ccc06ccdc3a4004002298103d87a8000132323300100100222533302100114c103d87a800013232323253330223371e014004266e95200033026375000297ae0133006006003375a60460066eb8c084008c094008c08c004dd59810180c801180c800991980080080211299980f0008a6103d87a8000132323232533301f3371e010004266e95200033023374c00297ae0133006006003375660400066eb8c078008c088008c0800048c06cc070c070c070c070004cdc199b8248008dd698009809008a4190024603260346034603460346034603460340022940c044020c8c8c8cc004004008894ccc06000452809919299980b99b8f00200614a226600800800260380046eb8c068004dd6180118080051bae3002300f00e23016301730173017301730173017301730170012301530163016301600137586026002602600260240026012006601e002601e004601a002600a00429309b2b19299980399b87480000044c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc070c07c00852616375a603a002603a0046eb4c06c004c06c008dd7180c800980c8011bae30170013017002375c602a002602a0046eb8c04c004c04c008dd6980880098088011bae300f001300f002375c601a002600a0082c600a0064600a6ea80048c00cdd5000ab9a5573aaae7955cfaba05742ae89",
"hash": "b23528245a8bd5c3a61a68b75ef33b057d114b3b2174f4d3f626a885"
}
],
"definitions": {
Expand Down
4 changes: 2 additions & 2 deletions validators/blockalpha.ak
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use aiken/transaction/value.{AssetName, PolicyId, lovelace_of, quantity_of}
use alphabid/constants.{demarket_addr, demarket_pct}
use alphabid/types.{VerificationKeyHash}
use alphabid/utils.{
check_address, check_amount, find_output, find_output_Winter,
check_address, check_amount, find_output, find_output_smc, find_output_Winter,
must_be_signed_by,
}

Expand Down Expand Up @@ -52,7 +52,7 @@ validator {

if !must_start_after(transaction.validity_range, datum.lock_until) {
let output_smc =
find_output(
find_output_smc(
outputs,
datum.price,
from_verification_key(datum.smc_address),
Expand Down

0 comments on commit 5b5d8d0

Please sign in to comment.