forked from oncyberio/factory
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f2e73d
commit 854292f
Showing
61 changed files
with
2,925 additions
and
10,206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,58 @@ | ||
import { BigNumber, Signer, utils } from 'ethers' | ||
|
||
export async function signMintingRequest( | ||
uri: string, | ||
amount: string, | ||
amountOncyber: string, | ||
nonce: string, | ||
minter: string, | ||
signer: Signer | ||
): Promise<string> { | ||
const aURI = utils.toUtf8Bytes(uri) | ||
const aAmount = utils.hexZeroPad(BigNumber.from(amount).toHexString(), 32) | ||
const aAmountOncyber = utils.hexZeroPad( | ||
BigNumber.from(amountOncyber).toHexString(), | ||
32 | ||
) | ||
const aNonce = utils.hexZeroPad(BigNumber.from(nonce).toHexString(), 32) | ||
const aMinter = utils.arrayify(minter) | ||
const message = utils.concat([aURI, aAmount, aAmountOncyber, aNonce, aMinter]) | ||
|
||
const hash = utils.keccak256(message) | ||
const aHash = utils.arrayify(hash) | ||
|
||
const signature = await signer.signMessage(aHash) | ||
return signature | ||
} | ||
|
||
export async function signMintingUtilityRequest( | ||
export async function signCreateDropRequest( | ||
uri: string, | ||
timeStart: number, | ||
timeEnd: number, | ||
price: number, | ||
priceStart: number, | ||
priceEnd: number, | ||
stepDuration: number, | ||
amountCap: number, | ||
shareCyber: number, | ||
nonce: string, | ||
minter: string, | ||
creator: string, | ||
nonce: number, | ||
signer: Signer | ||
): Promise<string> { | ||
const aURI = utils.toUtf8Bytes(uri) | ||
const aTimeStart = utils.hexZeroPad( | ||
const pUri = utils.toUtf8Bytes(uri) | ||
const pTimeStart = utils.hexZeroPad( | ||
BigNumber.from(timeStart).toHexString(), | ||
32 | ||
) | ||
const aTimeEnd = utils.hexZeroPad(BigNumber.from(timeEnd).toHexString(), 32) | ||
const aPrice = utils.hexZeroPad(BigNumber.from(price).toHexString(), 32) | ||
const aAmountCap = utils.hexZeroPad( | ||
const pTimeEnd = utils.hexZeroPad(BigNumber.from(timeEnd).toHexString(), 32) | ||
const pPriceStart = utils.hexZeroPad( | ||
BigNumber.from(priceStart).toHexString(), | ||
32 | ||
) | ||
const pPriceEnd = utils.hexZeroPad(BigNumber.from(priceEnd).toHexString(), 32) | ||
const pStepDuration = utils.hexZeroPad( | ||
BigNumber.from(stepDuration).toHexString(), | ||
32 | ||
) | ||
const pAmountCap = utils.hexZeroPad( | ||
BigNumber.from(amountCap).toHexString(), | ||
32 | ||
) | ||
const ashareCyber = utils.hexZeroPad( | ||
const pShareCyber = utils.hexZeroPad( | ||
BigNumber.from(shareCyber).toHexString(), | ||
32 | ||
) | ||
const aNonce = utils.hexZeroPad(BigNumber.from(nonce).toHexString(), 32) | ||
const aMinter = utils.arrayify(minter) | ||
const pCreator = utils.arrayify(creator) | ||
const pNonce = utils.hexZeroPad(BigNumber.from(nonce).toHexString(), 32) | ||
const message = utils.concat([ | ||
aURI, | ||
aTimeStart, | ||
aTimeEnd, | ||
aPrice, | ||
aAmountCap, | ||
ashareCyber, | ||
aNonce, | ||
aMinter, | ||
pUri, | ||
pTimeStart, | ||
pTimeEnd, | ||
pPriceStart, | ||
pPriceEnd, | ||
pStepDuration, | ||
pAmountCap, | ||
pShareCyber, | ||
pCreator, | ||
pNonce, | ||
]) | ||
|
||
const hash = utils.keccak256(message) | ||
const aHash = utils.arrayify(hash) | ||
const pHash = utils.arrayify(hash) | ||
|
||
const signature = await signer.signMessage(aHash) | ||
return signature | ||
return signer.signMessage(pHash) | ||
} |
Oops, something went wrong.