-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SignerBuilder and started WitnessRuleBuilder
- Loading branch information
1 parent
d421c59
commit a4c71f3
Showing
5 changed files
with
191 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// SignerBuilder.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using Neo.Cryptography.ECC; | ||
using Neo.Network.P2P.Payloads; | ||
|
||
namespace Neo.Builders | ||
{ | ||
public sealed class SignerBuilder | ||
{ | ||
private readonly Signer _signer = new Signer() | ||
{ | ||
AllowedContracts = [], | ||
AllowedGroups = [], | ||
Rules = [], | ||
Scopes = WitnessScope.None, | ||
}; | ||
|
||
private SignerBuilder(UInt160 scriptHash) | ||
{ | ||
_signer.Account = scriptHash; | ||
} | ||
|
||
public static SignerBuilder Create(UInt160 scriptHash) | ||
{ | ||
return new SignerBuilder(scriptHash); | ||
} | ||
|
||
public SignerBuilder AllowContract(UInt160 contractHash) | ||
{ | ||
_signer.AllowedContracts = [.. _signer.AllowedContracts, contractHash]; | ||
return this; | ||
} | ||
|
||
public SignerBuilder AllowGroup(ECPoint publicKey) | ||
{ | ||
_signer.AllowedGroups = [.. _signer.AllowedGroups, publicKey]; | ||
return this; | ||
} | ||
|
||
public SignerBuilder AddWitnessScope(WitnessScope scope) | ||
{ | ||
_signer.Scopes |= scope; | ||
return this; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// WitnessRuleBuilder.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using Neo.Network.P2P.Payloads; | ||
|
||
namespace Neo.Builders | ||
{ | ||
public sealed class WitnessRuleBuilder | ||
{ | ||
private readonly WitnessRule _rule = new(); | ||
|
||
private WitnessRuleBuilder(WitnessRuleAction action) | ||
{ | ||
_rule.Action = action; | ||
} | ||
|
||
public static WitnessRuleBuilder Create(WitnessRuleAction action) | ||
{ | ||
return new WitnessRuleBuilder(action); | ||
} | ||
} | ||
} |
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