@@ -39,37 +39,30 @@ export class UnmaskedPredicate extends DefaultPredicate {
3939 /**
4040 * Create unmasked predicate.
4141 *
42- * @param {Token } token token
42+ * @param {TokenId } tokenId token id
43+ * @param {TokenType } tokenType token type
44+ * @param {MintTransaction | TransferTransaction } transaction transaction
4345 * @param {SigningService } signingService signing service
4446 * @param {HashAlgorithm } hashAlgorithm hash algorithm
4547 */
46- public static createFromToken (
47- token : Token ,
48+ public static async create (
49+ tokenId : TokenId ,
50+ tokenType : TokenType ,
51+ transaction : MintTransaction | TransferTransaction ,
4852 signingService : SigningService ,
4953 hashAlgorithm : HashAlgorithm ,
5054 ) : Promise < UnmaskedPredicate > {
51- return UnmaskedPredicate . create ( token . id , token . type , token . latestTransaction , signingService , hashAlgorithm ) ;
52- }
55+ const nonce = await signingService . sign (
56+ await new DataHasher ( HashAlgorithm . SHA256 ) . update ( transaction . data . salt ) . digest ( ) ,
57+ ) ;
5358
54- /**
55- * Create unmasked predicate from mint transaction.
56- *
57- * @param {MintTransaction } transaction mint transaction
58- * @param {SigningService } signingService signing service
59- * @param {HashAlgorithm } hashAlgorithm hash algorithm
60- * @return predicate
61- */
62- public static createFromMintTransaction (
63- transaction : MintTransaction ,
64- signingService : SigningService ,
65- hashAlgorithm : HashAlgorithm ,
66- ) : Promise < UnmaskedPredicate > {
67- return UnmaskedPredicate . create (
68- transaction . data . tokenId ,
69- transaction . data . tokenType ,
70- transaction ,
71- signingService ,
59+ return new UnmaskedPredicate (
60+ tokenId ,
61+ tokenType ,
62+ signingService . publicKey ,
63+ signingService . algorithm ,
7264 hashAlgorithm ,
65+ nonce . bytes ,
7366 ) ;
7467 }
7568
@@ -97,36 +90,6 @@ export class UnmaskedPredicate extends DefaultPredicate {
9790 ) ;
9891 }
9992
100- /**
101- * Create unmasked predicate.
102- *
103- * @param {TokenId } tokenId token id
104- * @param {TokenType } tokenType token type
105- * @param {MintTransaction | TransferTransaction } transaction transaction
106- * @param {SigningService } signingService signing service
107- * @param {HashAlgorithm } hashAlgorithm hash algorithm
108- */
109- private static async create (
110- tokenId : TokenId ,
111- tokenType : TokenType ,
112- transaction : MintTransaction | TransferTransaction ,
113- signingService : SigningService ,
114- hashAlgorithm : HashAlgorithm ,
115- ) : Promise < UnmaskedPredicate > {
116- const nonce = await signingService . sign (
117- await new DataHasher ( HashAlgorithm . SHA256 ) . update ( transaction . data . salt ) . digest ( ) ,
118- ) ;
119-
120- return new UnmaskedPredicate (
121- tokenId ,
122- tokenType ,
123- signingService . publicKey ,
124- signingService . algorithm ,
125- hashAlgorithm ,
126- nonce . bytes ,
127- ) ;
128- }
129-
13093 /**
13194 * Verify token state for current transaction.
13295 *
0 commit comments